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

Unified Diff: third_party/WebKit/Source/platform/text/SegmentedString.h

Issue 2438263002: Possibly merge consecutive script fragments to reduce execution overhead
Patch Set: Created 4 years, 2 months 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 | « third_party/WebKit/Source/core/html/parser/HTMLTokenizer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/text/SegmentedString.h
diff --git a/third_party/WebKit/Source/platform/text/SegmentedString.h b/third_party/WebKit/Source/platform/text/SegmentedString.h
index 49f00fab74dedfefba7429f5165e6ea9da23c8b1..c803031fcc4eb89171fc247b07954f5e108a1f14 100644
--- a/third_party/WebKit/Source/platform/text/SegmentedString.h
+++ b/third_party/WebKit/Source/platform/text/SegmentedString.h
@@ -127,11 +127,28 @@ class PLATFORM_EXPORT SegmentedSubstring {
return *++m_data.string16Ptr;
}
+ UChar getCharByIndex8(unsigned index) {
+ ASSERT(m_data.string8Ptr);
+ m_data.string8Ptr += index;
+ return *m_data.string8Ptr;
+ }
+
+ UChar getCharByIndex16(unsigned index) {
+ ASSERT(m_data.string16Ptr);
+ m_data.string16Ptr += index;
+ return *m_data.string16Ptr;
+ }
+
String currentSubString(unsigned length) {
int offset = m_string.length() - m_length;
return m_string.substring(offset, length);
}
+ String currentSubString(unsigned pos, unsigned length) {
+ int offset = m_string.length() - m_length + pos;
+ return m_string.substring(offset, length);
+ }
+
ALWAYS_INLINE UChar getCurrentChar() {
ASSERT(m_length);
if (is8Bit())
@@ -146,6 +163,13 @@ class PLATFORM_EXPORT SegmentedSubstring {
return incrementAndGetCurrentChar16();
}
+ ALWAYS_INLINE UChar getCharByIndex(unsigned index) {
+ ASSERT(m_length - index);
+ if (is8Bit())
+ return getCharByIndex8(index);
+ return getCharByIndex16(index);
+ }
+
ALWAYS_INLINE bool haveOneCharacterLeft() const { return m_length == 1; }
ALWAYS_INLINE void decrementLength() { --m_length; }
@@ -303,6 +327,25 @@ class PLATFORM_EXPORT SegmentedString {
String toString() const;
UChar currentChar() const { return m_currentChar; }
+ SegmentedSubstring getCurrentString() const { return m_currentString; }
+
+ String getCurrentSubstring(unsigned length) {
+ return m_currentString.currentSubString(length);
+ }
+
+ String getCurrentSubstring(unsigned pos, unsigned length) {
+ return m_currentString.currentSubString(pos, length);
+ }
+
+ bool isEqualToScriptStartTagTemplate(const String& str) {
+ String stringTemplate("<script");
+ return equalPossiblyIgnoringCase(stringTemplate, str, true);
+ }
+
+ bool isEqualToScriptEndTagTemplate(const String& str) {
+ String stringTemplate("</script>");
+ return equalPossiblyIgnoringCase(stringTemplate, str, true);
+ }
// The method is moderately slow, comparing to currentLine method.
OrdinalNumber currentColumn() const;
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLTokenizer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698