Bug 46509

Summary: Add operator == for AtomicString and Vector<Uchar>
Product: WebKit Reporter: Erik Arvidsson <arv>
Component: New BugsAssignee: Erik Arvidsson <arv>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, bweinstein, darin, eric
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 20709    
Attachments:
Description Flags
Patch
none
Patch
none
Patch darin: review+

Erik Arvidsson
Reported 2010-09-24 14:13:55 PDT
Add operator == for AtomicString and Vector<Uchar>
Attachments
Patch (3.24 KB, patch)
2010-09-24 14:28 PDT, Erik Arvidsson
no flags
Patch (2.46 KB, patch)
2010-09-24 18:38 PDT, Erik Arvidsson
no flags
Patch (3.61 KB, patch)
2010-09-27 11:46 PDT, Erik Arvidsson
darin: review+
Erik Arvidsson
Comment 1 2010-09-24 14:28:00 PDT
Erik Arvidsson
Comment 2 2010-09-24 18:10:58 PDT
Darin suggested that I added this function in bug 20709.
Darin Adler
Comment 3 2010-09-24 18:21:54 PDT
Comment on attachment 68749 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=68749&action=review > JavaScriptCore/wtf/text/AtomicString.cpp:159 > +bool operator==(const AtomicString& a, const Vector<UChar>& b) Unlike strings, there is no concept of a null vector as distinct from an empty vector, so there should not be code here checking b.data() for null. > JavaScriptCore/wtf/text/AtomicString.cpp:161 > + StringImpl* impl = a.impl(); It doesn’t help readability or efficiency to put this into a local variable. > JavaScriptCore/wtf/text/AtomicString.cpp:163 > + if ((!impl || !impl->characters()) && !s) There’s no need to check null impl->characters(). > JavaScriptCore/wtf/text/AtomicString.cpp:167 > + return equal(impl, s, b.size()); This whole function can just be: return a.impl() && equal(a.impl(), b.data(), b.size()); No need for any other null checks.
Erik Arvidsson
Comment 4 2010-09-24 18:38:57 PDT
Darin Adler
Comment 5 2010-09-24 18:45:13 PDT
Comment on attachment 68799 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=68799&action=review > JavaScriptCore/wtf/text/AtomicString.h:129 > +inline bool operator==(const AtomicString& a, const Vector<UChar>& b) { return a.impl() && equal(a.impl(), b.data(), b.size()); } Oops! This won’t compile. The equal function this calls is inside AtomicString.cpp and private to the cpp file, not exposed to the header at all.
Erik Arvidsson
Comment 6 2010-09-24 18:46:41 PDT
Comment on attachment 68799 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=68799&action=review >> JavaScriptCore/wtf/text/AtomicString.h:129 >> +inline bool operator==(const AtomicString& a, const Vector<UChar>& b) { return a.impl() && equal(a.impl(), b.data(), b.size()); } > > Oops! This won’t compile. The equal function this calls is inside AtomicString.cpp and private to the cpp file, not exposed to the header at all. Yeah, I apologize for that patch upload. I'm moving it to the cpp and compiling and testing again.
Eric Seidel (no email)
Comment 7 2010-09-24 19:05:12 PDT
Erik Arvidsson
Comment 8 2010-09-27 11:46:44 PDT
Darin Adler
Comment 9 2010-09-27 11:47:34 PDT
Comment on attachment 68937 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=68937&action=review > JavaScriptCore/wtf/text/AtomicString.cpp:158 > } > +bool operator==(const AtomicString& a, const Vector<UChar>& b) There should be a blank line there. We could use the names "string" and "vector" instead of "a" and "b" here.
Erik Arvidsson
Comment 10 2010-09-27 12:22:40 PDT
Comment on attachment 68937 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=68937&action=review Thanks for your patience. >> JavaScriptCore/wtf/text/AtomicString.cpp:158 >> +bool operator==(const AtomicString& a, const Vector<UChar>& b) > > There should be a blank line there. > > We could use the names "string" and "vector" instead of "a" and "b" here. Done and done.
Erik Arvidsson
Comment 11 2010-09-27 13:43:56 PDT
Note You need to log in before you can comment on or make changes to this bug.