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

Unified Diff: Source/core/html/parser/HTMLParserIdioms.h

Issue 110843004: Replaced HTMLIdentifier with an atomized string factory function (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review fixes Created 7 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
« no previous file with comments | « Source/core/html/parser/HTMLIdentifier.cpp ('k') | Source/core/html/parser/HTMLParserIdioms.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLParserIdioms.h
diff --git a/Source/core/html/parser/HTMLParserIdioms.h b/Source/core/html/parser/HTMLParserIdioms.h
index 903ca5a37cd3a19b3e93bb5ef9dddd212368ff2b..16fd3eebe3cb808dd0252c35a69add4e9e9fb905 100644
--- a/Source/core/html/parser/HTMLParserIdioms.h
+++ b/Source/core/html/parser/HTMLParserIdioms.h
@@ -26,7 +26,6 @@
#define HTMLParserIdioms_h
#include "core/dom/QualifiedName.h"
-#include "core/html/parser/HTMLIdentifier.h"
#include "platform/Decimal.h"
#include "wtf/Forward.h"
#include "wtf/text/WTFString.h"
@@ -98,15 +97,31 @@ inline bool isNotHTMLSpace(CharType character)
}
bool threadSafeMatch(const QualifiedName&, const QualifiedName&);
-bool threadSafeMatch(const HTMLIdentifier&, const QualifiedName&);
-inline bool threadSafeHTMLNamesMatch(const HTMLIdentifier& tagName, const QualifiedName& qName)
+bool threadSafeMatch(const String&, const QualifiedName&);
+
+StringImpl* findStringIfStatic(const UChar* characters, unsigned length);
+
+enum CharacterWidth {
+ Likely8Bit,
+ Force8Bit,
+ Force16Bit
+};
+
+template<size_t inlineCapacity>
+static String attemptStaticStringCreation(const Vector<UChar, inlineCapacity>& vector, CharacterWidth width)
{
- // When the QualifiedName is known to HTMLIdentifier,
- // all we have to do is a pointer compare.
- ASSERT(HTMLIdentifier::isKnown(qName.localName().impl()));
- return tagName.asStringImpl() == qName.localName().impl();
+ String string(findStringIfStatic(vector.data(), vector.size()));
+ if (string.impl())
+ return string;
+ if (width == Likely8Bit)
+ string = StringImpl::create8BitIfPossible(vector);
+ else if (width == Force8Bit)
+ string = String::make8BitFrom16BitSource(vector);
+ else
+ string = String(vector);
+
+ return string;
}
}
-
#endif
« no previous file with comments | « Source/core/html/parser/HTMLIdentifier.cpp ('k') | Source/core/html/parser/HTMLParserIdioms.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698