Closed
Bug 337730
Opened 19 years ago
Closed 19 years ago
Add additional utilities to nsStringAPI
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: benjamin, Assigned: benjamin)
References
Details
Attachments
(1 file, 1 obsolete file)
61.58 KB,
patch
|
darin.moz
:
review+
|
Details | Diff | Splinter Review |
Porting additional string utilies to the frozen string API, as needed by camino and gnomevfs.
Assignee | ||
Comment 1•19 years ago
|
||
Attachment #221824 -
Flags: review?(darin)
Comment 2•19 years ago
|
||
Comment on attachment 221824 [details] [diff] [review]
Additional string utilities and tests, rev. 1
>Index: xpcom/glue/nsStringAPI.cpp
>+void
>+nsAString::Trim(const char *aSet, PRBool aLeading, PRBool aTrailing)
>+PRBool
>+nsAString::LowerCaseEqualsLiteral(const char *aASCIIString) const
>+{
>+ PRUint32 otherlen = strlen(aASCIIString);
Might be nice to avoid paying the cost of this strlen. Just walk
the two buffers looking for a terminator or begin==end.
>+static PRBool NS_strnmatch(const PRUnichar *aStr, const char* aSubstring,
>+static PRBool NS_strnimatch(const PRUnichar *aStr, const char* aSubstring,
Hrm... maybe these shouldn't use the NS_ prefix as that is generally
used for public facing APIs.
>+ // Set the new length.
>+ NS_StringGetMutableData(aString, end - start, &start);
>+}
Maybe this should just call SetLength.
>+PRInt32
>+CaseInsensitiveCompare(const char *a, const char *b,
>+ PRUint32 len)
>+{
>+ for (const char *aend = a + len; a < aend; ++a, ++b) {
>+ char la = NS_ToLower(*a);
>+ char lb = NS_ToLower(*b);
>+
>+ if (la == lb)
>+ continue;
>+
>+ return la < lb ? -1 : 1;
>+ }
>+
>+ return 0;
>+}
It seems like it would be beneficial if there was a way to get
direct access to kUpper2Lower (and kLower2Upper) to avoid the
function call overhead of NS_ToLower (and NS_ToUpper).
r=darin
Attachment #221824 -
Flags: review?(darin) → review+
Assignee | ||
Comment 3•19 years ago
|
||
Hopefully interdiff will make the change obvious here.
Attachment #221824 -
Attachment is obsolete: true
Comment 4•19 years ago
|
||
Comment on attachment 222675 [details] [diff] [review]
Additional string utilities and tests, rev. 1.1
>? xpcom/tests/external/Makefile.in
Forgot to cvs add?
>Index: xpcom/ds/nsCRT.h
...
> static PRUint32 strlen(const PRUnichar* s) {
>+ if (!s) {
>+ NS_ERROR("Passing null to nsCRT::strlen");
>+ return 0;
>+ }
> return NS_strlen(s);
> }
Add a TODO comment about removing this code eventually?
r=darin
Attachment #222675 -
Flags: review+
Assignee | ||
Comment 5•19 years ago
|
||
Fixed on trunk. Whittling away at the libxul-frozen-only dependency list continues!
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•