Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Unified Diff: third_party/WebKit/Source/core/dom/CompositorProxy.cpp

Issue 1552793002: CompositorWorker: Use a linear search in compositorMutablePropertyForName. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test which creates a 16-bit string for a valid property Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/CompositorProxy.cpp
diff --git a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
index c50fe8c6611bfd1203e576cec51eaeb3f79c77d5..f45d7ccd873781ab03c0e2647bde0a0d21b72021 100644
--- a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
+++ b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp
@@ -17,39 +17,23 @@
namespace blink {
-struct MutablePropertyMapping {
+static const struct {
const char* name;
- unsigned length;
WebCompositorMutableProperty property;
+} allowedProperties[] = {
+ { "opacity", WebCompositorMutablePropertyOpacity },
+ { "scrollleft", WebCompositorMutablePropertyScrollLeft },
+ { "scrolltop", WebCompositorMutablePropertyScrollTop },
+ { "transform", WebCompositorMutablePropertyTransform },
};
-// Warning: In order for std::lower_bound to work, the following must be in
-// alphabetical order.
-static MutablePropertyMapping allowedProperties[] = {
- { "opacity", 7, WebCompositorMutablePropertyOpacity },
- { "scrollleft", 10, WebCompositorMutablePropertyScrollLeft },
- { "scrolltop", 9, WebCompositorMutablePropertyScrollTop },
- { "transform", 9, WebCompositorMutablePropertyTransform },
-};
-
-static bool comparePropertyName(const MutablePropertyMapping& mapping, StringImpl* propertyLower)
-{
- ASSERT(propertyLower->is8Bit());
- return memcmp(mapping.name, propertyLower->characters8(), std::min(mapping.length, propertyLower->length())) < 0;
-}
-
static WebCompositorMutableProperty compositorMutablePropertyForName(const String& attributeName)
{
- WebCompositorMutableProperty property = WebCompositorMutablePropertyNone;
- const String attributeLower = attributeName.lower();
esprehn 2015/12/30 18:31:30 The only bug here is that this doesn't do .utf8().
- const MutablePropertyMapping* start = allowedProperties;
- const MutablePropertyMapping* end = allowedProperties + WTF_ARRAY_LENGTH(allowedProperties);
- if (attributeLower.impl()->is8Bit()) {
- const MutablePropertyMapping* match = std::lower_bound(start, end, attributeLower.impl(), comparePropertyName);
- if (match != end && equal(match->name, attributeLower.impl()))
- property = match->property;
+ for (const auto& mapping : allowedProperties) {
+ if (equalIgnoringCase(mapping.name, attributeName))
+ return mapping.property;
}
- return property;
+ return WebCompositorMutablePropertyNone;
}
static bool isControlThread()

Powered by Google App Engine
This is Rietveld 408576698