Closed Bug 617897 Opened 14 years ago Closed 11 years ago

Replace calls to AppendASCII('*') with Append('*')

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla23

People

(Reporter: alfredkayser, Assigned: orva)

References

(Blocks 1 open bug)

Details

(Keywords: memory-footprint, perf, Whiteboard: [mentor=Yoric][lang=c++])

Attachments

(1 file)

In mozilla/ xpcom/ io/ nsLocalFileWin.cpp  there are calls to AppendASCII which should be replaced by AppendLiteral, and for the case of one character with just Append('*') or Append('\\'); 
This prevent the need for a string, strlen, strcpy, etc.
Assignee: nobody → alfredkayser
http://mxr.mozilla.org/mozilla-central/search?string=AppendASCII%28%22&find=&findi=&filter=^[^\0]*%24&hitlimit=&tree=mozilla-central

The difference between AppendASCII("...") and AppendLiteral("...") is that the first also a does a "strlen" on the argument, whilst the second uses the compiler to pass the string length.
Keywords: footprint, perf
I can mentor that.
Whiteboard: [mentor=Yoric][lang=c++]
Attached patch patchSplinter Review
Simple patch, test cases left untouched. As this is my "low hanging fruit" to get familiar with Mozilla development process, all criticism is more than welcome.
Attachment #745201 - Flags: review?(dteller)
This looks good to me!

Nit:
In nsLocalFileWin.cpp, I would replace:
738     if (filename.Last() == L'/' || filename.Last() == L'\\')
739         filename.AppendASCII("*");
740     else 
741         filename.AppendASCII("\\*");
742 
743     filename.ReplaceChar(L'/', L'\\');

with:
     filename.ReplaceChar(L'/', L'\\');
     if (filename.Last() != L'\\') filename.Append('\\');
     filename.Append('*');

But that is probably best for another bug.
Assignee: alfredkayser → iivari.aikas
Status: NEW → ASSIGNED
Comment on attachment 745201 [details] [diff] [review]
patch

Review of attachment 745201 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me, too.
Passing to someone who has review rights on that directory.
Attachment #745201 - Flags: review?(dteller)
Attachment #745201 - Flags: review?(doug.turner)
Attachment #745201 - Flags: feedback+
Attachment #745201 - Flags: review?(doug.turner) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/865b9be24831
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Blocks: 869826
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: