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

Unified Diff: src/factory.cc

Issue 17176021: Merged r15193, r15263, r15267 into trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 8b842a733928f7425f73870b8c61523bc03ac84c..10e70d909fdbf98be99fd436768170d9e621d3bb 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -259,6 +259,32 @@ Handle<String> Factory::NewConsString(Handle<String> first,
}
+template<typename SinkChar, typename StringType>
+Handle<String> ConcatStringContent(Handle<StringType> result,
+ Handle<String> first,
+ Handle<String> second) {
+ DisallowHeapAllocation pointer_stays_valid;
+ SinkChar* sink = result->GetChars();
+ String::WriteToFlat(*first, sink, 0, first->length());
+ String::WriteToFlat(*second, sink + first->length(), 0, second->length());
+ return result;
+}
+
+
+Handle<String> Factory::NewFlatConcatString(Handle<String> first,
+ Handle<String> second) {
+ int total_length = first->length() + second->length();
+ if (first->IsOneByteRepresentationUnderneath() &&
+ second->IsOneByteRepresentationUnderneath()) {
+ return ConcatStringContent<uint8_t>(
+ NewRawOneByteString(total_length), first, second);
+ } else {
+ return ConcatStringContent<uc16>(
+ NewRawTwoByteString(total_length), first, second);
+ }
+}
+
+
Handle<String> Factory::NewSubString(Handle<String> str,
int begin,
int end) {
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698