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

Unified Diff: src/scanner.h

Issue 113336: Optimize the lexical scanner by selective inlining, and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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 | « no previous file | src/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.h
===================================================================
--- src/scanner.h (revision 1926)
+++ src/scanner.h (working copy)
@@ -39,16 +39,33 @@
UTF8Buffer();
~UTF8Buffer();
- void Initialize(char* src, int length);
- void AddChar(uc32 c);
- void Reset() { pos_ = 0; }
- int pos() const { return pos_; }
+ void AddChar(uc32 c) {
+ if (cursor_ <= limit_ &&
+ static_cast<unsigned>(c) <= unibrow::Utf8::kMaxOneByteChar) {
+ *cursor_++ = static_cast<char>(c);
+ } else {
+ AddCharSlow(c);
+ }
+ }
+
+ void Reset() { cursor_ = data_; }
+ int pos() const { return cursor_ - data_; }
char* data() const { return data_; }
private:
char* data_;
- int size_;
- int pos_;
+ char* cursor_;
+ char* limit_;
+
+ int Capacity() const {
+ return (limit_ - data_) + unibrow::Utf8::kMaxEncodedSize;
+ }
+
+ static char* ComputeLimit(char* data, int capacity) {
+ return (data + capacity) - unibrow::Utf8::kMaxEncodedSize;
+ }
+
+ void AddCharSlow(uc32 c);
};
@@ -204,7 +221,7 @@
void Advance();
void PushBack(uc32 ch);
- void SkipWhiteSpace(bool initial);
+ bool SkipWhiteSpace();
Token::Value SkipSingleLineComment();
Token::Value SkipMultiLineComment();
@@ -212,7 +229,6 @@
inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_);
void Scan();
- Token::Value ScanToken();
void ScanDecimalDigits();
Token::Value ScanNumber(bool seen_period);
Token::Value ScanIdentifier();
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698