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

Unified Diff: src/objects.cc

Issue 11231: Flat string reader (Closed)
Patch Set: Created 12 years, 1 month 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
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 23bd4c0976651c66d6d89b6250facf489053b116..9f4f5cf41b271a7fb86585f98637ef1a08e94885 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -3501,6 +3501,57 @@ const unibrow::byte* String::ReadBlock(String* input,
}
+FlatStringReader* FlatStringReader::top_ = NULL;
Erik Corry 2008/11/19 09:45:38 Some people don't like static initializers. Perha
Christian Plesner Hansen 2008/11/19 10:15:26 I don't think initialization of pointers to NULL a
+
+
+FlatStringReader::FlatStringReader(Handle<String> str)
+ : str_(str.location()),
+ length_(str->length()),
+ prev_(top_) {
+ top_ = this;
+ RefreshState();
+}
+
+
+FlatStringReader::FlatStringReader(Vector<const char> input)
+ : str_(NULL),
+ is_ascii_(true),
+ length_(input.length()),
+ start_(input.start()),
+ prev_(top_) {
+ top_ = this;
+}
+
+
+FlatStringReader::~FlatStringReader() {
+ ASSERT_EQ(top_, this);
+ top_ = prev_;
+}
+
+
+void FlatStringReader::RefreshState() {
+ if (str_ == NULL) return;
+ Handle<String> str(str_);
+ StringShape shape(*str);
+ ASSERT(str->IsFlat(shape));
+ is_ascii_ = shape.IsAsciiRepresentation();
+ if (is_ascii_) {
+ start_ = str->ToAsciiVector().start();
+ } else {
+ start_ = str->ToUC16Vector().start();
+ }
+}
+
+
+void FlatStringReader::PostGarbageCollectionProcessing() {
+ FlatStringReader* current = top_;
+ while (current != NULL) {
+ current->RefreshState();
+ current = current->prev_;
+ }
+}
+
+
void StringInputBuffer::Seek(unsigned pos) {
Reset(pos, input_);
}
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698