Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 41c3edc707095d860703378924a2ce85d83ea7c4..b53d167e5461d5abe5caa0844a84d6b27ca82f21 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -11708,6 +11708,9 @@ bool String::SlowAsArrayIndex(uint32_t* index) { |
Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) { |
+ Heap* heap = string->GetHeap(); |
+ if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
+ |
int new_size, old_size; |
int old_length = string->length(); |
if (old_length <= new_length) return string; |
@@ -11727,7 +11730,6 @@ Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) { |
DCHECK_OBJECT_ALIGNED(start_of_string); |
DCHECK_OBJECT_ALIGNED(start_of_string + new_size); |
- Heap* heap = string->GetHeap(); |
// Sizes are pointer size aligned, so that we can use filler objects |
// that are a multiple of pointer size. |
heap->CreateFillerObjectAt(start_of_string + new_size, delta, |
@@ -11738,7 +11740,6 @@ Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) { |
// for the left-over space to avoid races with the sweeper thread. |
string->synchronized_set_length(new_length); |
- if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
return string; |
} |