From 84eea3e5311762d0c2c7ae42cb9903a41ca24771 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Wed, 29 Feb 2012 14:25:24 +0000 Subject: [PATCH] Inline one level of recursive call of WriteToFlat for the common case of cons string list. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/9536011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10871 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 538986d..bc0a82e 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -6862,10 +6862,21 @@ void String::WriteToFlat(String* src, // Left hand side is longer. Recurse over right. if (to > boundary) { String* second = cons_string->second(); - WriteToFlat(second, - sink + boundary - from, - 0, + // When repeatedly appending to a string, we get a cons string that + // is unbalanced to the left, a list, essentially. We inline the + // common case of sequential ascii right child. + if (to - boundary == 1) { + sink[boundary - from] = static_cast(second->Get(0)); + } else if (second->IsSeqAsciiString()) { + CopyChars(sink + boundary - from, + SeqAsciiString::cast(second)->GetChars(), to - boundary); + } else { + WriteToFlat(second, + sink + boundary - from, + 0, + to - boundary); + } to = boundary; } source = first; -- 2.7.4