Closed Bug 406169 Opened 17 years ago Closed 17 years ago

Move some of nsIDBFolderInfo to ns*String and help migration to frozen linkage

Categories

(MailNews Core :: Backend, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: standard8, Assigned: standard8)

References

Details

Attachments

(1 file, 4 obsolete files)

Attached patch The fix (obsolete) (deleted) — Splinter Review
I was looking at migrating some more of mailnews/base to frozen linkage and it quickly became clear that moving some more of the nsIDBFolderInfo from string to nsCString would be a lot more sensible than reworking the code twice.

Hence patch attached does some string tidy up in nsIDBFolderInfo (and the associated changes) and there's a couple of small frozen linkage changes in there.

Note, I also decided it was approprate to rename {G,S}etCharPtrProperty to {G,S}CharProperty now we're no longer using string pointers there.

Neil, can you review the mailnews changes, Phil could you review the TB-specific changes?
Attachment #290873 - Flags: superreview?(neil)
Attachment #290873 - Flags: review?(philringnalda)
Attachment #290873 - Flags: review?(neil)
Attached patch The fix v2 (obsolete) (deleted) — Splinter Review
Correct version, this has an optimisation to an if statement that I forgot to regenerate the patch for.
Attachment #290873 - Attachment is obsolete: true
Attachment #290875 - Flags: superreview?(neil)
Attachment #290875 - Flags: review?(philringnalda)
Attachment #290875 - Flags: review?(neil)
Attachment #290873 - Flags: superreview?(neil)
Attachment #290873 - Flags: review?(philringnalda)
Attachment #290873 - Flags: review?(neil)
Comment on attachment 290875 [details] [diff] [review]
The fix v2

>+  ACString getCharProperty(in ACString propertyName);
>+  void setCharProperty(in ACString aPropertyName, in ACString aPropertyValue);
Although it is correct to make the values ACString, the property names themselves should stay string.

>   void getCharacterSet(out ACString charSet, out boolean overriden);
>-  void setCharacterSet(in string charSet);
>+  void setCharacterSet(in ACString charSet);
> 
>   attribute boolean characterSetOverride;
> 
>-  string getCharPtrCharacterSet();
>+  readonly attribute ACString charPtrCharacterSet;
I don't see anyone using getCharacterSet, so I would change those three methods into an attribute ACString characterSet.

>+static nsCString gDefaultCharacterSet;
No static strings. Try making it a member of gFolderCharsetObserver instead?
Attachment #290875 - Flags: superreview?(neil)
Attachment #290875 - Flags: superreview-
Attachment #290875 - Flags: review?(neil)
Comment on attachment 290875 [details] [diff] [review]
The fix v2

I'll update the patch in a bit.
Attachment #290875 - Flags: review?(philringnalda)
OK, so as Mark pointed out nsMsgDBFolder.cpp does uses GetCharacterSet, but my MXR search didn't find it because I searched case-sensitively for FolderInfo.

folderInfo->GetCharacterSet(mCharset, &defaultUsed);
if (defaultUsed)
  mCharset.Truncate();

Since this caller only wants the folder info's m_charSet (and not the gDefaultCharacterSet) it makes sense to use attribute ACString characterSet; and change this call to folderInfo->GetCharacterSet(mCharset);

We can then replace the uses of Get[Const]CharPtrCharacterSet with a readonly attribute, perhaps call it effectiveCharacterSet?
Attached patch The fix v3 (obsolete) (deleted) — Splinter Review
Revised patch as per discussion with Neil and to fix the static string problem.
Attachment #290875 - Attachment is obsolete: true
Attachment #291225 - Flags: superreview?(neil)
Attachment #291225 - Flags: review?(philringnalda)
Attachment #291225 - Flags: review?(neil)
Comment on attachment 291225 [details] [diff] [review]
The fix v3

>-  nsCString     m_charSet;
I don't claim to understand the perf/bloat aspects of this change...

>-          if (gDefaultCharacterSet)
>-            nsMemory::Free(gDefaultCharacterSet);
>-          gDefaultCharacterSet = ToNewCString(ucsval);
>+          *gDefaultCharacterSet = NS_ConvertUTF16toUTF8(ucsval);
You don't null-check gDefaultCharacterSet. Also, please use CopyUTF16toUTF8.

>+          if (!gDefaultCharacterSet)
>+            gDefaultCharacterSet = new nsCString;
>+
>+          *gDefaultCharacterSet = NS_ConvertUTF16toUTF8(ucsval);
Same here - the new might fail...
Attachment #291225 - Flags: review?(neil) → review+
Comment on attachment 291225 [details] [diff] [review]
The fix v3

> NS_IMETHODIMP
>-nsDBFolderInfo::GetCharPtrCharacterSet(char **result)
>+nsDBFolderInfo::GetEffectiveCharacterSet(nsACString &result)
> {
>-  *result = ToNewCString(m_charSet);
This gets called a lot, particularly from nsMsgDBView::GetCellText.
Removing m_charSet isn't really an option.
Attachment #291225 - Flags: superreview?(neil) → superreview-
Attached patch The fix v4 (obsolete) (deleted) — Splinter Review
Updated per Neil's comments.
Attachment #291225 - Attachment is obsolete: true
Attachment #291949 - Flags: superreview?(neil)
Attachment #291949 - Flags: review?(philringnalda)
Attachment #291949 - Flags: review?(neil)
Attachment #291225 - Flags: review?(philringnalda)
Comment on attachment 291949 [details] [diff] [review]
The fix v4

Sorry, attached the wrong patch :-(
Attachment #291949 - Attachment is obsolete: true
Attachment #291949 - Flags: superreview?(neil)
Attachment #291949 - Flags: review?(philringnalda)
Attachment #291949 - Flags: review?(neil)
Attached patch The fix v4 (deleted) — Splinter Review
The right patch this time.
Attachment #292052 - Flags: superreview?(neil)
Attachment #292052 - Flags: review?(philringnalda)
Attachment #292052 - Flags: review?(neil)
Comment on attachment 292052 [details] [diff] [review]
The fix v4

>+            CopyUTF16toUTF8(ucsval, *gDefaultCharacterSet);
Right :-)

>+            *gDefaultCharacterSet = NS_ConvertUTF16toUTF8(ucsval);
Wrong ;-)

>+  if (NS_FAILED(GetCharProperty(kCharacterSetColumnName, result)) ||
>+      result.IsEmpty() && gDefaultCharacterSet)
You need extra parens here because && has higher precedence than ||.
r+sr=me with that fixed.
Attachment #292052 - Flags: superreview?(neil)
Attachment #292052 - Flags: superreview+
Attachment #292052 - Flags: review?(neil)
Attachment #292052 - Flags: review+
Comment on attachment 292052 [details] [diff] [review]
The fix v4

r=me on the parts I understand ;)
Attachment #292052 - Flags: review?(philringnalda) → review+
Patch checked in -> fixed.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: