WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
53266
Add WTFString method to compare equality with Vector<UChar>
https://bugs.webkit.org/show_bug.cgi?id=53266
Summary
Add WTFString method to compare equality with Vector<UChar>
Adam Barth
Reported
2011-01-27 16:17:26 PST
Add WTFString method to compare equality with Vector<UChar>
Attachments
Patch
(2.48 KB, patch)
2011-01-27 16:18 PST
,
Adam Barth
eric
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Adam Barth
Comment 1
2011-01-27 16:18:35 PST
Created
attachment 80373
[details]
Patch
Eric Seidel (no email)
Comment 2
2011-01-27 16:59:49 PST
Comment on
attachment 80373
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=80373&action=review
Seems OK.
> Source/JavaScriptCore/wtf/text/StringImpl.h:366 > + if (!a.size()) > + return true; > + return !memcmp(a.data(), b->characters(), b->length());
Is calling memcmp with length = 0 OK? If so then you don't need the !a.size() check.
Adam Barth
Comment 3
2011-01-27 17:04:14 PST
Comment on
attachment 80373
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=80373&action=review
>> Source/JavaScriptCore/wtf/text/StringImpl.h:366 >> + if (!a.size()) >> + return true; >> + return !memcmp(a.data(), b->characters(), b->length()); > > Is calling memcmp with length = 0 OK? If so then you don't need the !a.size() check.
Sounds dodgy:
http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-07/0109.html
Darin Adler
Comment 4
2011-01-27 17:45:14 PST
(In reply to
comment #3
)
> > Is calling memcmp with length = 0 OK? If so then you don't need the !a.size() check. > > Sounds dodgy: >
http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-07/0109.html
Why the FUD? memcpy with length == 0 is definitely OK!
Darin Adler
Comment 5
2011-01-27 17:45:27 PST
(In reply to
comment #4
)
> Why the FUD? memcpy with length == 0 is definitely OK!
I mean memcmp.
Adam Barth
Comment 6
2011-01-27 17:55:53 PST
> Why the FUD? memcpy with length == 0 is definitely OK!
Even if one of the pointers is NULL?
Darin Adler
Comment 7
2011-01-27 18:03:31 PST
(In reply to
comment #6
)
> > Why the FUD? memcmp with length == 0 is definitely OK! > > Even if one of the pointers is NULL?
In practice, yes. I am pretty damned sure of this. And I think we rely on it. But the C standard does use wording that makes it seem a little ambiguous.
Adam Barth
Comment 8
2011-01-27 18:15:10 PST
Okiedokes. Thanks.
Adam Barth
Comment 9
2011-01-27 18:21:05 PST
Committed
r76894
: <
http://trac.webkit.org/changeset/76894
>
WebKit Review Bot
Comment 10
2011-01-27 19:47:31 PST
Attachment 80373
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/7597383
WebKit Review Bot
Comment 11
2011-01-27 20:27:11 PST
http://trac.webkit.org/changeset/76894
might have broken GTK Linux 64-bit Debug
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug