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

Unified Diff: src/json-parser.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
« no previous file with comments | « no previous file | src/json-stringifier.h » ('j') | src/json-stringifier.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-parser.h
diff --git a/src/json-parser.h b/src/json-parser.h
index 28ef8b33c8be019fb465830650d48bf41c40b23b..be0c86a7b035fe9fd01db25dac656f754935863c 100644
--- a/src/json-parser.h
+++ b/src/json-parser.h
@@ -580,22 +580,16 @@ Handle<String> JsonParser<seq_ascii>::SlowScanJsonString(
Advance();
}
}
- // Shrink seq_string length to count.
- if (isolate()->heap()->InNewSpace(*seq_str)) {
- isolate()->heap()->new_space()->
- template ShrinkStringAtAllocationBoundary<StringType>(
- *seq_str, count);
- } else {
- int string_size = StringType::SizeFor(count);
- int allocated_string_size = StringType::SizeFor(length);
- int delta = allocated_string_size - string_size;
- Address start_filler_object = seq_str->address() + string_size;
- seq_str->set_length(count);
- isolate()->heap()->CreateFillerObjectAt(start_filler_object, delta);
- }
+
ASSERT_EQ('"', c0_);
// Advance past the last '"'.
AdvanceSkipWhitespace();
+
+ // Shrink seq_string length to count and return.
Hannes Payer (out of office) 2013/03/21 12:48:30 See comment in src/objects.h. I would let Truncate
+ if (count == 0) {
+ return isolate_->factory()->empty_string();
+ }
+ SeqString::cast(*seq_str)->Truncate(count);
return seq_str;
}
@@ -623,8 +617,8 @@ Handle<String> JsonParser<seq_ascii>::ScanJsonString() {
int beg_pos = position_;
position_ = position;
return SlowScanJsonString<SeqOneByteString, uint8_t>(source_,
- beg_pos,
- position_);
+ beg_pos,
+ position_);
}
if (c0 < 0x20) return Handle<String>::null();
if (static_cast<uint32_t>(c0) >
« no previous file with comments | « no previous file | src/json-stringifier.h » ('j') | src/json-stringifier.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698