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

Unified Diff: src/objects.cc

Issue 18552: Fix bug where strings were not flattened before regexp. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | « 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
===================================================================
--- src/objects.cc (revision 1138)
+++ src/objects.cc (working copy)
@@ -587,7 +587,7 @@
}
-Object* String::Flatten(StringShape shape) {
+Object* String::TryFlatten(StringShape shape) {
#ifdef DEBUG
// Do not attempt to flatten in debug mode when allocation is not
// allowed. This is to avoid an assertion failure when allocating.
@@ -604,11 +604,11 @@
// SlicedStrings.
String* buf = ss->buffer();
ASSERT(!buf->IsSlicedString());
- Object* ok = buf->Flatten(StringShape(buf));
+ Object* ok = buf->TryFlatten(StringShape(buf));
if (ok->IsFailure()) return ok;
- // Under certain circumstances (TryFlatten fails in String::Slice)
- // we can have a cons string under a slice. In this case we need
- // to get the flat string out of the cons!
+ // Under certain circumstances (TryFlattenIfNotFlat fails in
+ // String::Slice) we can have a cons string under a slice.
+ // In this case we need to get the flat string out of the cons!
if (StringShape(String::cast(ok)).IsCons()) {
ss->set_buffer(ConsString::cast(ok)->first());
}
@@ -2413,8 +2413,8 @@
return Heap::undefined_value();
}
- // TryFlatten before operating on the string.
- name->TryFlatten(StringShape(name));
+ // Try to flatten before operating on the string.
+ name->TryFlattenIfNotFlat(StringShape(name));
// Make sure name is not an index.
uint32_t index;
@@ -3065,9 +3065,7 @@
// doesn't make Utf8Length faster, but it is very likely that
// the string will be accessed later (for example by WriteUtf8)
// so it's still a good idea.
- if (!IsFlat(shape)) {
- TryFlatten(shape); // shape is now no longer valid.
- }
+ TryFlattenIfNotFlat(shape); // shape is now no longer valid.
Access<StringInputBuffer> buffer(&string_input_buffer);
buffer->Reset(0, this);
int result = 0;
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698