Closed
Bug 67577
Opened 24 years ago
Closed 24 years ago
basic_nsAReadableString<CharT>::Equals should short circuit
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla0.9
People
(Reporter: jband_mozilla, Assigned: scc)
References
Details
I think the template method...
PRBool
basic_nsAReadableString<CharT>::Equals( const basic_nsAReadableString<CharT>&
rhs ) const
...should short-circuit when Length() != rhs.Length(). This might often avoid
lots of unnecessary groveling through the chars in Compare. In cases where the
lengths are equal the cost of this check is a duplicated pair of Length() calls
- since ::Compare will itself still need to do this.
I have no numbers to show this as a win, only my guess. Do with it what you will
:)
Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9
Assignee | ||
Comment 1•24 years ago
|
||
Here's a patch ---
Index: mozilla/string/public/nsAReadableString.h
===================================================================
RCS file: /cvsroot/mozilla/string/public/nsAReadableString.h,v
retrieving revision 1.93
diff -u -2 -r1.93 nsAReadableString.h
--- nsAReadableString.h 2001/02/07 03:04:46 1.93
+++ nsAReadableString.h 2001/02/23 00:50:01
@@ -516,5 +516,5 @@
basic_nsAReadableString<CharT>::Equals( const basic_nsAReadableString<CharT>&
rhs ) const
{
- return Compare(rhs) == 0;
+ return Length() == rhs.Length() && Compare(rhs) == 0;
}
Comment 2•24 years ago
|
||
r=jag
Comment 4•24 years ago
|
||
sr=hyatt
Assignee | ||
Comment 5•24 years ago
|
||
fix checked in, thanks guys. Hope this makes you happy, jband.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•