[webkit-reviews] review granted: [Bug 128893] jsDocumentPrototypeFunctionGetElementById should not create an AtomicString for the function argument : [Attachment 224340] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Feb 19 10:49:28 PST 2014


Darin Adler <darin at apple.com> has granted Benjamin Poulain
<benjamin at webkit.org>'s request for review:
Bug 128893: jsDocumentPrototypeFunctionGetElementById should not create an
AtomicString for the function argument
https://bugs.webkit.org/show_bug.cgi?id=128893

Attachment 224340: Patch
https://bugs.webkit.org/attachment.cgi?id=224340&action=review

------- Additional Comments from Darin Adler <darin at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=224340&action=review


Seems to me that in the future we might want to have functions like this take a
StringView rather than a const String&.

> Source/WTF/wtf/text/AtomicString.cpp:407
> +AtomicStringImpl* AtomicString::findStringWithHash(const StringImpl*
stringImpl)

Since you’re renaming this, I suggest also changing it to take a reference
instead of a pointer.

> Source/WTF/wtf/text/AtomicString.cpp:452
> +AtomicStringImpl* AtomicString::findSlowCase(StringImpl* string)

Seems like this should take a reference rather than a pointer.

> Source/WTF/wtf/text/AtomicString.cpp:454
> +    ASSERT_WITH_MESSAGE(!string->isAtomic(), "We should not hit the slow
case if the string is already atomic.");

Message seems to just repeat what the assertion says, not sure it’s helpful.

> Source/WTF/wtf/text/AtomicString.cpp:461
> +    HashSet<StringImpl*>& atomicStringTable = stringTable();
> +    auto iterator = atomicStringTable.find(string);
> +    if (iterator != atomicStringTable.end())
> +	   return static_cast<AtomicStringImpl*>(*iterator);
> +    return nullptr;

We really should add HashSet::get for cases like this one. If that existed,
then this would be:

    return static_cast<AtomicStringImpl*>(stringTable().get(string));

I think that reads much better than the 5 lines of code above.

> Source/WebCore/ChangeLog:31
> +	   When getting and AtomicString, the case of a empty string is not
important, use isNull() instead.

typo: "and" instead of "an"


More information about the webkit-reviews mailing list