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

Unified Diff: src/json-stringifier.h

Issue 12440061: Improve SeqString::Truncate for latest allocated strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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
Index: src/json-stringifier.h
diff --git a/src/json-stringifier.h b/src/json-stringifier.h
index 418d4794595367f088e09cbb519d65209ff7bd96..355c4fcb1fe9ca170e8d9a1573312afe5b55bbb0 100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -322,15 +322,8 @@ MaybeObject* BasicJsonStringifier::StringifyString_(Isolate* isolate,
dest->GetChars() + 1,
string->length());
dest->Set(final_size++, '\"');
- if (isolate->heap()->InNewSpace(*result)) {
- // In new space, simply lower the allocation top to fit the actual size.
- isolate->heap()->new_space()->ShrinkStringAtAllocationBoundary<StringType>(
- *result, final_size);
- return *result;
- } else {
- // Not in new space, need to fill the wasted space with filler objects.
- return SeqString::cast(*result)->Truncate(final_size);
- }
+ SeqString::cast(*result)->Truncate(final_size);
+ return *result;
}
@@ -697,8 +690,11 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject(
void BasicJsonStringifier::ShrinkCurrentPart() {
ASSERT(current_index_ < part_length_);
- current_part_ = Handle<String>(
- SeqString::cast(*current_part_)->Truncate(current_index_), isolate_);
+ if (current_index_ == 0) {
Hannes Payer (out of office) 2013/03/21 12:48:30 Again, Truncate() should do the right thing for yo
+ current_part_ = isolate_->factory()->empty_string();
+ } else {
+ SeqString::cast(*current_part_)->Truncate(current_index_);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698