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

Unified Diff: runtime/vm/scanner.cc

Issue 315303002: Improve scanner performance by remembering string's CharAt function as the string type does not cha… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« runtime/vm/object.cc ('K') | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.cc
===================================================================
--- runtime/vm/scanner.cc (revision 37049)
+++ runtime/vm/scanner.cc (working copy)
@@ -58,7 +58,8 @@
: source_(src),
source_length_(src.Length()),
saved_context_(NULL),
- private_key_(String::ZoneHandle(private_key.raw())) {
+ private_key_(String::ZoneHandle(private_key.raw())),
+ char_at_func_(src.CharAtFunc()) {
Reset();
}
@@ -154,11 +155,11 @@
if (!str.IsOneByteString()) {
return false;
}
- if (str.Length() == 0 || !IsIdentStartChar(str.CharAt(0))) {
+ if (str.Length() == 0 || !IsIdentStartChar(CallCharAt()(str, 0))) {
return false;
}
for (int i = 1; i < str.Length(); i++) {
- if (!IsIdentChar(str.CharAt(i))) {
+ if (!IsIdentChar(CallCharAt()(str, i))) {
return false;
}
}
@@ -202,7 +203,7 @@
newline_seen_ = true;
c0_pos_.line++;
c0_pos_.column = 0;
- if (source_.CharAt(lookahead_pos_) == '\r') {
+ if (CallCharAt()(source_, lookahead_pos_) == '\r') {
// Replace a sequence of '\r' '\n' with a single '\n'.
if (LookaheadChar(1) == '\n') {
lookahead_pos_++;
@@ -227,7 +228,7 @@
ASSERT(how_many >= 0);
int32_t lookahead_char = '\0';
if (lookahead_pos_ + how_many < source_length_) {
- lookahead_char = source_.CharAt(lookahead_pos_ + how_many);
+ lookahead_char = CallCharAt()(source_, lookahead_pos_ + how_many);
}
return lookahead_char;
}
@@ -282,7 +283,7 @@
ASSERT(allow_dollar || (c0_ != '$'));
int ident_length = 0;
int ident_pos = lookahead_pos_;
- int32_t ident_char0 = source_.CharAt(ident_pos);
+ int32_t ident_char0 = CallCharAt()(source_, ident_pos);
while (IsIdentChar(c0_) && (allow_dollar || (c0_ != '$'))) {
ReadChar();
ident_length++;
@@ -298,7 +299,8 @@
const char* keyword = keywords_[i].keyword_chars;
int char_pos = 1;
while ((char_pos < ident_length) &&
- (keyword[char_pos] == source_.CharAt(ident_pos + char_pos))) {
+ (keyword[char_pos] ==
+ CallCharAt()(source_, ident_pos + char_pos))) {
char_pos++;
}
if (char_pos == ident_length) {
« runtime/vm/object.cc ('K') | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698