Closed Bug 387023 Opened 17 years ago Closed 17 years ago

Minor string cleanup in nsAtomTable.cpp

Categories

(Core :: XPCOM, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sharparrow1, Assigned: sharparrow1)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch Patch (obsolete) — Splinter Review
Avoid a bit of potential unnecessary string copying and make nsStaticAtomWrapper hold onto its string directly.
Attachment #271117 - Flags: review?(benjamin)
Comment on attachment 271117 [details] [diff] [review]
Patch

There's more simplification that really needs to be done; the PromiseFloatString call in NS_NewAtom actually seems to take up a non-trivial amount of time.
Attachment #271117 - Flags: review?(benjamin)
Attached patch Patch v2 (obsolete) — Splinter Review
Some small stuff, could lead to a minor perf improvement by avoiding calling PromiseFlatString and avoiding string copies in some cases.
Assignee: nobody → sharparrow1
Attachment #271117 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #278119 - Flags: review?(benjamin)
Comment on attachment 278119 [details] [diff] [review]
Patch v2

Oops, wrong version.
Attachment #278119 - Attachment is obsolete: true
Attachment #278119 - Flags: review?(benjamin)
Attached patch Patch v3Splinter Review
All right, here's the right version.
Attachment #278120 - Flags: review?(benjamin)
Comment on attachment 278120 [details] [diff] [review]
Patch v3

>Index: nsAtomTable.cpp

>-      CompareUTF8toUTF16(nsDependentCString(atomString, he->getLength()),
>-                         nsDependentString(strKey->getUTF16String(),
>-                                           strKey->getLength())) == 0;
>+      CompareUTF8toUTF16(nsDependentCSubstring(atomString, atomString + he->getLength()),
>+                         nsDependentSubstring(strKey->getUTF16String(),
>+                                              strKey->getUTF16String() + strKey->getLength())) == 0;

I understand all the changes except for this one. Why did you need to change to the substring type here?
I don't think it's legal to use nsDependentString on a buffer that isn't guaranteed to be null-terminated.  I don't think it actually matters here, though, because CompareUTF8toUTF16 doesn't happen to care.
Attachment #278120 - Flags: review?(benjamin) → review+
Attachment #278120 - Flags: approval1.9?
Comment on attachment 278120 [details] [diff] [review]
Patch v3

a=bzbarsky assuming he .NET thing still compiles
Attachment #278120 - Flags: approval1.9? → approval1.9+
Checked in.
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.

Attachment

General

Creator:
Created:
Updated:
Size: