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}
This commit is contained in:
vogelheim 2016-04-28 04:21:34 -07:00 committed by Commit bot
parent 9a93964503
commit 5e9b1eb3b5

View File

@ -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();
}
}
}