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

Unified Diff: src/factory.cc

Issue 2065053002: ZoneVector overload of Factory::NewStringFromTwoByte (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: static_cast Created 4 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') | no next file » | 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 cee362588050ce732da537a0bc6a0a60fb84fcf4..0ad99a61e41dffc7279be56b0fe2371bff40b19c 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -292,12 +292,10 @@ MaybeHandle<String> Factory::NewStringFromUtf8(Vector<const char> string,
return result;
}
-
-MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
+MaybeHandle<String> Factory::NewStringFromTwoByte(const uc16* string,
+ int length,
PretenureFlag pretenure) {
- int length = string.length();
- const uc16* start = string.start();
- if (String::IsOneByte(start, length)) {
+ if (String::IsOneByte(string, length)) {
if (length == 1) return LookupSingleCharacterStringFromCode(string[0]);
Handle<SeqOneByteString> result;
ASSIGN_RETURN_ON_EXCEPTION(
@@ -305,7 +303,7 @@ MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
result,
NewRawOneByteString(length, pretenure),
String);
- CopyChars(result->GetChars(), start, length);
+ CopyChars(result->GetChars(), string, length);
return result;
} else {
Handle<SeqTwoByteString> result;
@@ -314,11 +312,21 @@ MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
result,
NewRawTwoByteString(length, pretenure),
String);
- CopyChars(result->GetChars(), start, length);
+ CopyChars(result->GetChars(), string, length);
return result;
}
}
+MaybeHandle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
+ PretenureFlag pretenure) {
+ return NewStringFromTwoByte(string.start(), string.length(), pretenure);
+}
+
+MaybeHandle<String> Factory::NewStringFromTwoByte(
+ const ZoneVector<uc16>* string, PretenureFlag pretenure) {
+ return NewStringFromTwoByte(string->data(), static_cast<int>(string->size()),
+ pretenure);
+}
Handle<String> Factory::NewInternalizedStringFromUtf8(Vector<const char> str,
int chars,
« no previous file with comments | « src/factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698