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

Unified Diff: src/objects-inl.h

Issue 143303002: Experimental lexer: add handling of sliced strings in SubStringKey (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Fix typo Created 6 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 73fc0a6b71ff1912188bc1c4e05f73931294bee3..961041c05dd22d13be79a10564fd8f17bae0005f 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -503,7 +503,12 @@ template<class Char>
class SubStringKey : public HashTableKey {
public:
SubStringKey(Handle<String> string, int from, int length)
- : string_(string), from_(from), length_(length) { }
+ : string_(string), from_(from), length_(length) {
+ if (string_->IsSlicedString()) {
+ string_ = Handle<String>(Unslice(*string_, &from_));
+ }
+ ASSERT(string_->IsSeqString() || string->IsExternalString());
+ }
virtual uint32_t Hash() {
ASSERT(length_ >= 0);
@@ -525,6 +530,14 @@ class SubStringKey : public HashTableKey {
private:
const Char* GetChars();
+ String* Unslice(String* string, int* offset) {
+ while (string->IsSlicedString()) {
+ SlicedString* sliced = SlicedString::cast(string);
+ *offset += sliced->offset();
+ string = sliced->parent();
+ }
+ return string;
+ }
Handle<String> string_;
int from_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698