Revision: 17370
Author:   [email protected]
Date:     Thu Oct 24 11:00:07 2013 UTC
Log:      Experimental scanner: save all token data into one vector.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/39673002
http://code.google.com/p/v8/source/detail?r=17370

Modified:
 /branches/experimental/parser/src/lexer/experimental-scanner.cc
 /branches/experimental/parser/src/lexer/experimental-scanner.h

=======================================
--- /branches/experimental/parser/src/lexer/experimental-scanner.cc Mon Oct 21 15:30:42 2013 UTC +++ /branches/experimental/parser/src/lexer/experimental-scanner.cc Thu Oct 24 11:00:07 2013 UTC
@@ -75,12 +75,8 @@
   if (read_all_at_once_) {
     source_ = ReadFile(fname, isolate, &length_);
     token_.resize(1500);
-    beg_.resize(1500);
-    end_.resize(1500);
   } else {
     token_.resize(BUFFER_SIZE);
-    beg_.resize(BUFFER_SIZE);
-    end_.resize(BUFFER_SIZE);
   }
 }

@@ -108,17 +104,17 @@
 Token::Value ExperimentalScanner::Next() {
   while (current_ == fetched_)
     FillTokens();
-  return token_[current_++];
+  return token_[current_++].value;
 }


 Token::Value ExperimentalScanner::current_token() {
-  return token_[current_ - 1];
+  return token_[current_ - 1].value;
 }


 ExperimentalScanner::Location ExperimentalScanner::location() {
-  return Location(beg_[current_ - 1], end_[current_ - 1]);
+  return Location(token_[current_ - 1].beg, token_[current_ - 1].end);
 }


@@ -126,12 +122,10 @@
   if (token == Token::EOS) end--;
   if (fetched_ >= token_.size()) {
     token_.resize(token_.size() * 2);
-    beg_.resize(beg_.size() * 2);
-    end_.resize(end_.size() * 2);
   }
-  token_[fetched_] = token;
-  beg_[fetched_] = beg;
-  end_[fetched_] = end;
+  token_[fetched_].value = token;
+  token_[fetched_].beg = beg;
+  token_[fetched_].end = end;
   fetched_++;
 }

=======================================
--- /branches/experimental/parser/src/lexer/experimental-scanner.h Mon Oct 21 15:30:42 2013 UTC +++ /branches/experimental/parser/src/lexer/experimental-scanner.h Thu Oct 24 11:00:07 2013 UTC
@@ -54,6 +54,11 @@
     int end_pos;
   };

+  struct SavedToken {
+    int beg, end;
+    Token::Value value;
+  };
+
   ExperimentalScanner(const char* fname,
                       bool read_all_at_once,
                       Isolate* isolate);
@@ -68,9 +73,7 @@
  private:
   void FillTokens();
   static const int BUFFER_SIZE = 256;
-  std::vector<v8::internal::Token::Value> token_;
-  std::vector<int> beg_;
-  std::vector<int> end_;
+  std::vector<SavedToken> token_;
   size_t current_;
   size_t fetched_;
   FILE* file_;

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to