Title: [292329] branches/safari-613-branch/Source/WebCore/html/InputType.cpp
- Revision
- 292329
- Author
- [email protected]
- Date
- 2022-04-04 14:55:27 -0700 (Mon, 04 Apr 2022)
Log Message
Cherry-pick r289691. rdar://91259284
Look up InputTypeFactoryMap with an ASCII lowercase string instead of using a ASCIICaseInsensitiveHash
https://bugs.webkit.org/show_bug.cgi?id=236532
Reviewed by Myles C. Maxfield.
InputType::create looks up the InputTypeFactoryMap based on the
AtomString value of the <input type> attribute. The HashMap uses an
ASCIICaseInsensitiveHash, but the AtomStrings stored in the map are all
ASCII lowercase to begin with. This means that we spend time doing an
ASCII case insensitive hash computation on the query string. Most
content already supplies an ASCII lowercase type value, so it's less
work to ASCII lowercase the type value and then look up the HashMap
using the regular hash for AtomStrings (i.e., pulling the hash out of
AtomString).
Doing this is a 0.5% improvement on a couple of Speedometer 2 subtests,
and a 0.1% improvement to the overall score.
html/InputType.cpp:
(WebCore::InputType::create):
Modified Paths
Diff
Modified: branches/safari-613-branch/Source/WebCore/html/InputType.cpp (292328 => 292329)
--- branches/safari-613-branch/Source/WebCore/html/InputType.cpp 2022-04-04 21:55:25 UTC (rev 292328)
+++ branches/safari-613-branch/Source/WebCore/html/InputType.cpp 2022-04-04 21:55:27 UTC (rev 292329)
@@ -90,7 +90,7 @@
typedef bool (Settings::*InputTypeConditionalFunction)() const;
typedef const AtomString& (*InputTypeNameFunction)();
typedef Ref<InputType> (*InputTypeFactoryFunction)(HTMLInputElement&);
-typedef HashMap<AtomString, std::pair<InputTypeConditionalFunction, InputTypeFactoryFunction>, ASCIICaseInsensitiveHash> InputTypeFactoryMap;
+typedef HashMap<AtomString, std::pair<InputTypeConditionalFunction, InputTypeFactoryFunction>> InputTypeFactoryMap;
template<class T> static Ref<InputType> createInputType(HTMLInputElement& element)
{
@@ -150,7 +150,7 @@
{
if (!typeName.isEmpty()) {
static NeverDestroyed factoryMap = createInputTypeFactoryMap();
- auto&& [conditional, factory] = factoryMap.get().get(typeName);
+ auto&& [conditional, factory] = factoryMap.get().get(typeName.convertToASCIILowercase());
if (factory && (!conditional || std::invoke(conditional, element.document().settings())))
return factory(element);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes