Commit 5e9b1eb3 authored by vogelheim's avatar vogelheim Committed by Commit bot

Prevent unnecessary memory (de-)allocations in LiteralBuffer::CopyFrom.

BUG=v8:4947
LOG=Y

Review-Url: https://codereview.chromium.org/1919673006
Cr-Commit-Position: refs/heads/master@{#35857}
parent 9a939645
......@@ -225,8 +225,14 @@ class LiteralBuffer {
} else {
is_one_byte_ = other->is_one_byte_;
position_ = other->position_;
backing_store_.Dispose();
backing_store_ = other->backing_store_.Clone();
if (position_ < backing_store_.length()) {
std::copy(other->backing_store_.begin(),
other->backing_store_.begin() + position_,
backing_store_.begin());
} else {
backing_store_.Dispose();
backing_store_ = other->backing_store_.Clone();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment