Closed
Bug 225887
Opened 22 years ago
Closed 22 years ago
trivial optimization in nsCharTraits.h
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: dwitte, Assigned: dwitte)
References
Details
Attachments
(2 files)
806 bytes,
patch
|
jag+mozilla
:
review+
alecf
:
superreview+
|
Details | Diff | Splinter Review |
739 bytes,
patch
|
bryner
:
review+
alecf
:
superreview+
dbaron
:
approval1.6b+
|
Details | Diff | Splinter Review |
http://lxr.mozilla.org/seamonkey/source/xpcom/string/public/nsCharTraits.h#175
there's no need for two |if| tests... we can just return the difference if the
two chars aren't equal. we use memcmp elsewhere in nsCharTraits, whose return
values aren't restricted to {-1,0,1}... so this optimization is unlikely to
cause a problem.
![]() |
Assignee | |
Comment 1•22 years ago
|
||
![]() |
Assignee | |
Updated•22 years ago
|
Attachment #135653 -
Flags: superreview?(alecf)
Attachment #135653 -
Flags: review?(jag)
![]() |
||
Comment 2•22 years ago
|
||
Comment on attachment 135653 [details] [diff] [review]
fix
yay! less branching.
sr=alecf
![]() |
||
Comment 3•22 years ago
|
||
Comment on attachment 135653 [details] [diff] [review]
fix
yay! less branching.
sr=alecf
Attachment #135653 -
Flags: superreview?(alecf) → superreview+
Comment 4•22 years ago
|
||
Comment on attachment 135653 [details] [diff] [review]
fix
Why not simply:
#else
return to_int_type(*s1 - *s2);
#endif
![]() |
Assignee | |
Comment 5•22 years ago
|
||
we want to compare the whole string, right?
(sorry about lack of context in the diff, see lxr link in comment 0)
Comment 6•22 years ago
|
||
Comment on attachment 135653 [details] [diff] [review]
fix
Duh, the for loop was enough context. pebcak (it was too early in the morning
to review). r=jag
Attachment #135653 -
Flags: review?(jag) → review+
![]() |
Assignee | |
Comment 7•22 years ago
|
||
np :)
fixed.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
![]() |
||
Comment 8•22 years ago
|
||
Whoa, this isn't right. to_int_type does an intermediate cast to PRUint16, so
the resulting code is similar to:
return int((unsigned short)(*s1 - *s2));
which returns 65535 for *s1 = 'a', *s2 = 'b'.
This broke sorting in the Linux filepicker and probably other places.
![]() |
Assignee | |
Comment 9•22 years ago
|
||
right - i actually suspected that might be a problem, and tested it before i
landed. my testing showed it was fine, so maybe i made a mistake when testing...
sigh :/
thanks for the report. patch coming up.
![]() |
Assignee | |
Comment 10•22 years ago
|
||
![]() |
Assignee | |
Comment 11•22 years ago
|
||
Comment on attachment 135987 [details] [diff] [review]
le fix
this look ok, alecf?
Attachment #135987 -
Flags: superreview?(alecf)
Attachment #135987 -
Flags: review?(alecf)
![]() |
||
Comment 12•22 years ago
|
||
Comment on attachment 135987 [details] [diff] [review]
le fix
oh, duh :)
sr=alecf
Attachment #135987 -
Flags: superreview?(alecf) → superreview+
![]() |
Assignee | |
Comment 13•22 years ago
|
||
*** Bug 226310 has been marked as a duplicate of this bug. ***
![]() |
||
Updated•22 years ago
|
Attachment #135987 -
Flags: review?(alecf) → review+
![]() |
Assignee | |
Updated•22 years ago
|
Attachment #135987 -
Flags: approval1.6b?
Attachment #135987 -
Flags: approval1.6b? → approval1.6b+
![]() |
Assignee | |
Comment 14•22 years ago
|
||
checked in.
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•