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

Unified Diff: src/parsing/scanner.h

Issue 1919673006: Prevent unnecessary memory (de-)allocations in LiteralBuffer::CopyFrom. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/scanner.h
diff --git a/src/parsing/scanner.h b/src/parsing/scanner.h
index 22c504c98ea206b760d84ae76b8bb85b5ddfe81c..0bb18679c525aea7154dbbb687494e366b923511 100644
--- a/src/parsing/scanner.h
+++ b/src/parsing/scanner.h
@@ -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();
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698