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

Unified Diff: src/objects-inl.h

Issue 6302: Stricter String->IsFlat. (Closed)
Patch Set: Created 12 years, 2 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 | test/mjsunit/switch.js » ('j') | 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 decaf392f6d999002e9d9db5eaaf22f587e100de..a612ba984cc86e534669b9513cb7f87478179c56 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1321,17 +1321,17 @@ StringRepresentationTag String::map_representation_tag(Map* map) {
bool String::IsFlat() {
- String* current = this;
- while (true) {
- switch (current->representation_tag()) {
- case kConsStringTag:
- return String::cast(ConsString::cast(current)->second())->length() == 0;
- case kSlicedStringTag:
- current = String::cast(SlicedString::cast(this)->buffer());
- break;
- default:
- return true;
+ switch (this->representation_tag()) {
+ case kConsStringTag:
+ // Only flattened strings have second part empty.
+ return String::cast(ConsString::cast(this)->second())->length() == 0;
+ case kSlicedStringTag: {
+ String* slice = String::cast(SlicedString::cast(this)->buffer());
+ StringRepresentationTag tag = slice->representation_tag();
+ return tag == kSeqStringTag || tag == kExternalStringTag;
}
+ default:
+ return true;
}
}
« no previous file with comments | « no previous file | test/mjsunit/switch.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698