Closed
Bug 478732
Opened 17 years ago
Closed 17 years ago
nsLocalFileWin::InitWithPath is inefficient
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: neil, Assigned: neil)
Details
(Keywords: perf)
Attachments
(1 file, 2 obsolete files)
|
3.01 KB,
patch
|
benjamin
:
review+
mozilla
:
review+
|
Details | Diff | Splinter Review |
It clones and adopts the input path, which also means that if anyone wants the path (e.g. Clone, GetPath) it gets copied each time. I did an unscientific test (startup and shutdown with sessionstore enabled) without and with the following patch and obtained the following statistics:
5.1% fewer allocations/frees
2.6% fewer reallocations (no idea why)
4.7% extra shares (these would have been copies)
50% fewer adoptions/frees
95% fewer copies of adopted buffers (wow!)
16% extra copies of auto buffers (presumably callers to InitWithPath)
| Assignee | ||
Comment 1•17 years ago
|
||
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #362573 -
Flags: review?(mozilla)
Attachment #362573 -
Flags: review?(benjamin)
Updated•17 years ago
|
Attachment #362573 -
Flags: review?(mozilla) → review-
Comment 2•17 years ago
|
||
Comment on attachment 362573 [details] [diff] [review]
Proposed patch
In the OS/2 version you removed the definition of the path variable but not all usages. Did you mean to change those to filePath somehow?
| Assignee | ||
Comment 3•17 years ago
|
||
Thanks for spotting that. Here's an updated patch.
Attachment #362573 -
Attachment is obsolete: true
Attachment #363097 -
Flags: review?(mozilla)
Attachment #363097 -
Flags: review?(benjamin)
Attachment #362573 -
Flags: review?(benjamin)
Comment 4•17 years ago
|
||
Comment on attachment 363097 [details] [diff] [review]
Hopefully fixed OS/2
There's still pathLen... I think one could make the OS/2 code even more Windows-like with this:
PRInt32 len = filePath.Length() - 1;
mWorkingPath = filePath;
if (filePath[len] == '\\' && !::isleadbyte(filePath[len-1]))
mWorkingPath.Truncate(len);
| Assignee | ||
Comment 5•17 years ago
|
||
I tried to make it even slightly more like the Windows code.
Attachment #363097 -
Attachment is obsolete: true
Attachment #363220 -
Flags: review?(mozilla)
Attachment #363220 -
Flags: review?(benjamin)
Attachment #363097 -
Flags: review?(mozilla)
Attachment #363097 -
Flags: review?(benjamin)
Comment 6•17 years ago
|
||
Comment on attachment 363220 [details] [diff] [review]
Third time lucky?
Yes, this time it not only looks correct, I also tested and it works. Thanks, Neil!
Attachment #363220 -
Flags: review?(mozilla) → review+
Updated•17 years ago
|
Attachment #363220 -
Flags: review?(benjamin) → review+
| Assignee | ||
Comment 7•17 years ago
|
||
Pushed changeset 1288e7384c7f to mozilla-central.
Actually I pushed this yesterday but I spent so long gazing at tinderboxpushlog that I forgot to update the bug ;-)
| Assignee | ||
Comment 8•17 years ago
|
||
It would help if I marked this fixed too... obviously I haven't woken up yet.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•