Bug 55645

Summary: DatasetDOMStringMap::item and ::contains copies attribute name string
Product: WebKit Reporter: Emil A Eklund <eae>
Component: DOMAssignee: Emil A Eklund <eae>
Status: RESOLVED FIXED    
Severity: Enhancement CC: abarth, commit-queue, dglazkov, mitz, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch none

Emil A Eklund
Reported 2011-03-02 19:02:59 PST
DatasetDOMStringMap::item and DatasetDOMStringMap::contains both use propertyNameMatchesAttributeName to match dataset property names with attribute names. The current implementation does this matching by creating a new string that's converted from a attribute name to a property name. It also loops over the attribute string twice (first to check if it's valid and then to create the copy). This is unnecessary and rather inefficient.
Attachments
Patch (4.42 KB, patch)
2011-03-02 19:05 PST, Emil A Eklund
no flags
Emil A Eklund
Comment 1 2011-03-02 19:05:38 PST
Dimitri Glazkov (Google)
Comment 2 2011-03-29 11:03:23 PDT
Comment on attachment 84510 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=84510&action=review Ask abarth to take a gander, I am not very well-versed in character encodings and the challenges sorrounding them. I am just scared of them :) > Source/WebCore/dom/DatasetDOMStringMap.cpp:-80 > - String convertedName = convertAttributeNameToPropertyName(attributeName); Do we still need this helper? > Source/WebCore/dom/DatasetDOMStringMap.cpp:95 > + if (attribute[a] == '-' && a + 1 < attributeLength && attribute[a + 1] != '-') > + wordBoundary = true; > + else { > + if ((wordBoundary ? toASCIIUpper(attribute[a]) : attribute[a]) != property[p]) > + return false; > + p++; > + wordBoundary = false; > + } > + a++; Will this still work with non-ASCII characters?
Emil A Eklund
Comment 3 2011-03-29 11:31:23 PDT
Comment on attachment 84510 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=84510&action=review >> Source/WebCore/dom/DatasetDOMStringMap.cpp:-80 >> - String convertedName = convertAttributeNameToPropertyName(attributeName); > > Do we still need this helper? Yeah, at least for now. It's used in one more place. >> Source/WebCore/dom/DatasetDOMStringMap.cpp:95 >> + a++; > > Will this still work with non-ASCII characters? No, but then again neither will convertAttributeNameToPropertyName.
Dimitri Glazkov (Google)
Comment 4 2011-03-29 11:33:47 PDT
Comment on attachment 84510 [details] Patch alrighty.
WebKit Commit Bot
Comment 5 2011-03-29 15:07:37 PDT
The commit-queue encountered the following flaky tests while processing attachment 84510 [details]: http/tests/inspector/console-websocket-error.html bug 57392 (authors: pfeldman@chromium.org and yutak@chromium.org) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 6 2011-03-29 15:10:28 PDT
Comment on attachment 84510 [details] Patch Clearing flags on attachment: 84510 Committed r82332: <http://trac.webkit.org/changeset/82332>
WebKit Commit Bot
Comment 7 2011-03-29 15:10:33 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.