Commit 4ebd97b4 authored by verwaest's avatar verwaest Committed by Commit bot

Optimize flattening of cons strings with equal left and right-side.

This significantly speeds up flattening repeat strings (e.g., '.'.repeat(1000)).

BUG=

Review URL: https://codereview.chromium.org/1798073002

Cr-Commit-Position: refs/heads/master@{#34751}
parent 3941f347
......@@ -11539,6 +11539,10 @@ void String::WriteToFlat(String* src,
// Right hand side is longer. Recurse over left.
if (from < boundary) {
WriteToFlat(first, sink, from, boundary);
if (from == 0 && cons_string->second() == first) {
CopyChars(sink + boundary, sink, boundary);
return;
}
sink += boundary - from;
from = 0;
} else {
......
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