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

Unified Diff: src/parsing/scanner.h

Issue 2044233004: Speed up adding literal chars when the buffer is known to be one-byte (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/parsing/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/scanner.h
diff --git a/src/parsing/scanner.h b/src/parsing/scanner.h
index 0acc7ab019a1c7e033ec9160d905990b4419b1bf..a71770083d66efaef26de6b272533de4110d8228 100644
--- a/src/parsing/scanner.h
+++ b/src/parsing/scanner.h
@@ -148,17 +148,27 @@ class DuplicateFinder {
char number_buffer_[kBufferSize];
};
-
// ----------------------------------------------------------------------------
// LiteralBuffer - Collector of chars of literals.
+const int kMaxAscii = 127;
+
class LiteralBuffer {
public:
LiteralBuffer() : is_one_byte_(true), position_(0), backing_store_() { }
~LiteralBuffer() { backing_store_.Dispose(); }
- INLINE(void AddChar(uint32_t code_unit)) {
+ INLINE(void AddChar(char code_unit)) {
+ if (position_ >= backing_store_.length()) ExpandBuffer();
+ DCHECK(is_one_byte_);
+ DCHECK(0 <= code_unit && code_unit <= kMaxAscii);
+ backing_store_[position_] = static_cast<byte>(code_unit);
+ position_ += kOneByteSize;
+ return;
+ }
+
+ INLINE(void AddChar(uc32 code_unit)) {
if (position_ >= backing_store_.length()) ExpandBuffer();
if (is_one_byte_) {
if (code_unit <= unibrow::Latin1::kMaxChar) {
@@ -557,6 +567,11 @@ class Scanner {
next_.literal_chars->AddChar(c);
}
+ INLINE(void AddLiteralChar(char c)) {
+ DCHECK_NOT_NULL(next_.literal_chars);
+ next_.literal_chars->AddChar(c);
+ }
+
INLINE(void AddRawLiteralChar(uc32 c)) {
DCHECK_NOT_NULL(next_.raw_literal_chars);
next_.raw_literal_chars->AddChar(c);
« no previous file with comments | « no previous file | src/parsing/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698