[webkit-reviews] review granted: [Bug 91320] Accessing the last item in children should be a constant time operation : [Attachment 152418] Fixes the bug

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jul 14 09:41:49 PDT 2012


Ojan Vafai <ojan at chromium.org> has granted Ryosuke Niwa <rniwa at webkit.org>'s
request for review:
Bug 91320: Accessing the last item in children should be a constant time
operation
https://bugs.webkit.org/show_bug.cgi?id=91320

Attachment 152418: Fixes the bug
https://bugs.webkit.org/attachment.cgi?id=152418&action=review

------- Additional Comments from Ojan Vafai <ojan at chromium.org>
View in context: https://bugs.webkit.org/attachment.cgi?id=152418&action=review


> Source/WebCore/html/HTMLCollection.cpp:336
> +    if (isLengthCacheValid() && supportsItemBefore() &&
isLastItemCloserThanLastOrCachedItem(offset)) {
> +	   // FIXME: Need to figure out the last offset in array for
HTMLFormCollection and HTMLPropertiesCollection
> +	   unsigned unusedOffsetInArray = 0;
> +	   Node* lastItem = itemBefore(unusedOffsetInArray, 0);
> +	   ASSERT(!unusedOffsetInArray);
> +	   ASSERT(lastItem);
> +	   setItemCache(lastItem, cachedLength() - 1, 0);
> +    } else if (!isItemCacheValid() ||
isFirstItemCloserThanCachedItem(offset) || (!supportsItemBefore() && offset <
cachedItemOffset())) {

This would probably be more readable if you had shouldSearchFromFirstItem and
shouldSearchFromLastItem helper functions.


More information about the webkit-reviews mailing list