Last Comment Bug 617897 - Replace calls to AppendASCII('*') with Append('*')
: Replace calls to AppendASCII('*') with Append('*')
Status: RESOLVED FIXED
[mentor=Yoric][lang=c++]
: footprint, perf
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla23
Assigned To: Iivari Äikäs [:orva]
:
Mentors:
Depends on:
Blocks: 869826
  Show dependency treegraph
 
Reported: 2010-12-09 03:13 PST by Alfred Kayser
Modified: 2013-05-08 00:47 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (9.56 KB, patch)
2013-05-03 09:20 PDT, Iivari Äikäs [:orva]
dougt: review+
dteller: feedback+
Details | Diff | Splinter Review

Description Alfred Kayser 2010-12-09 03:13:08 PST
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.
Comment 1 Alfred Kayser 2013-03-07 02:15:40 PST
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.
Comment 2 David Rajchenbach-Teller [:Yoric] (please use "needinfo") 2013-03-07 06:37:16 PST
I can mentor that.
Comment 3 Iivari Äikäs [:orva] 2013-05-03 09:20:45 PDT
Created attachment 745201 [details] [diff] [review]
patch

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.
Comment 4 Alfred Kayser 2013-05-04 02:23:32 PDT
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.
Comment 5 David Rajchenbach-Teller [:Yoric] (please use "needinfo") 2013-05-05 04:52:50 PDT
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.
Comment 6 Ryan VanderMeulen [:RyanVM] 2013-05-07 07:29:18 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/865b9be24831
Comment 7 Ryan VanderMeulen [:RyanVM] 2013-05-07 19:36:18 PDT
https://hg.mozilla.org/mozilla-central/rev/865b9be24831

Note You need to log in before you can comment on or make changes to this bug.