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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h

Issue 1920583002: NOT FOR LANDING: Hack up CSSParser for speed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing consts. Created 4 years, 8 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
Index: third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h
diff --git a/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h b/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h
index b8a2f480df9071103c9bfae8978b5d7d2d3cce6c..4185753751bf66b8fd6b4ee11383c90b28837837 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h
+++ b/third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h
@@ -5,6 +5,7 @@
#ifndef CSSTokenizerInputStream_h
#define CSSTokenizerInputStream_h
+#include "core/html/parser/InputStreamPreprocessor.h"
#include "wtf/text/WTFString.h"
namespace blink {
@@ -13,21 +14,25 @@ struct CSSParserString;
class CSSTokenizerInputStream {
WTF_MAKE_NONCOPYABLE(CSSTokenizerInputStream);
- USING_FAST_MALLOC(CSSTokenizerInputStream);
+ DISALLOW_NEW();
esprehn 2016/04/22 23:30:58 always on the stack or a member :)
public:
- CSSTokenizerInputStream(String input);
+ explicit CSSTokenizerInputStream(const String& input)
+ : m_offset(0)
+ , m_string(input.impl())
+ {
+ }
- UChar peek(unsigned);
- inline UChar nextInputChar()
esprehn 2016/04/22 23:30:58 missing const on both, also don't need inline in t
+ UChar peek(unsigned) const;
+ UChar nextInputChar() const
{
return peek(0);
}
// For fast-path code, don't replace nulls with replacement characters
- UChar peekWithoutReplacement(unsigned lookaheadOffset)
+ UChar peekWithoutReplacement(unsigned lookaheadOffset) const
{
- ASSERT((m_offset + lookaheadOffset) <= m_stringLength);
- if ((m_offset + lookaheadOffset) == m_stringLength)
+ ASSERT((m_offset + lookaheadOffset) <= length());
+ if ((m_offset + lookaheadOffset) == length())
return '\0';
return (*m_string)[m_offset + lookaheadOffset];
}
@@ -35,25 +40,39 @@ public:
void advance(unsigned offset = 1) { m_offset += offset; }
void pushBack(UChar);
- double getDouble(unsigned start, unsigned end);
esprehn 2016/04/22 23:30:58 missing const
+ double getDouble(unsigned start, unsigned end) const;
template<bool characterPredicate(UChar)>
unsigned skipWhilePredicate(unsigned offset)
{
- while ((m_offset + offset) < m_stringLength && characterPredicate((*m_string)[m_offset + offset]))
+ while ((m_offset + offset) < length() && characterPredicate((*m_string)[m_offset + offset]))
++offset;
return offset;
}
- unsigned offset() const { return std::min(m_offset, m_stringLength); }
+ unsigned length() const { return m_string->length(); }
+ unsigned offset() const { return std::min(m_offset, length()); }
CSSParserString rangeAsCSSParserString(unsigned start, unsigned length) const;
private:
- size_t m_offset;
- const size_t m_stringLength;
esprehn 2016/04/22 23:30:58 There's no reason to store the length, we have it
+ unsigned m_offset;
const RefPtr<StringImpl> m_string;
};
+inline UChar CSSTokenizerInputStream::peek(unsigned lookaheadOffset) const
+{
+ if ((m_offset + lookaheadOffset) >= length())
+ return kEndOfFileMarker;
+ UChar result = (*m_string)[m_offset + lookaheadOffset];
+ return result ? result : 0xFFFD;
+}
+
+inline void CSSTokenizerInputStream::pushBack(UChar cc)
+{
+ --m_offset;
+ ASSERT(nextInputChar() == cc);
+}
+
} // namespace blink
#endif // CSSTokenizerInputStream_h

Powered by Google App Engine
This is Rietveld 408576698