Last Comment Bug 617897 - Replace calls to AppendASCII('*') with Append('*')
: Replace calls to AppendASCII('*') with Append('*')
: footprint, perf
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: unspecified
: All All
-- normal (vote)
: mozilla23
Assigned To: Iivari Äikäs [:orva]
: Nathan Froyd [:froydnj]
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:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

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

Description User image 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 User image Alfred Kayser 2013-03-07 02:15:40 PST^[^\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 User image David Teller [:Yoric] (please use "needinfo") 2013-03-07 06:37:16 PST
I can mentor that.
Comment 3 User image Iivari Äikäs [:orva] 2013-05-03 09:20:45 PDT
Created attachment 745201 [details] [diff] [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.
Comment 4 User image Alfred Kayser 2013-05-04 02:23:32 PDT
This looks good to me!

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

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

But that is probably best for another bug.
Comment 5 User image David Teller [:Yoric] (please use "needinfo") 2013-05-05 04:52:50 PDT
Comment on attachment 745201 [details] [diff] [review]

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

Looks good to me, too.
Passing to someone who has review rights on that directory.
Comment 6 User image Ryan VanderMeulen [:RyanVM] 2013-05-07 07:29:18 PDT
Comment 7 User image Ryan VanderMeulen [:RyanVM] 2013-05-07 19:36:18 PDT

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