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

Unified Diff: src/api.cc

Issue 42423: Add a public API for using an empty sring. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 1555)
+++ src/api.cc (working copy)
@@ -2472,9 +2472,17 @@
}
+Local<String> v8::String::Empty() {
+ EnsureInitialized("v8::String::Empty()");
+ LOG_API("String::Empty()");
+ return Utils::ToLocal(i::Factory::empty_symbol());
+}
+
+
Local<String> v8::String::New(const char* data, int length) {
EnsureInitialized("v8::String::New()");
LOG_API("String::New(char)");
+ if (length == 0) return Empty();
if (length == -1) length = strlen(data);
i::Handle<i::String> result =
i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length));
@@ -2503,6 +2511,7 @@
Local<String> v8::String::New(const uint16_t* data, int length) {
EnsureInitialized("v8::String::New()");
LOG_API("String::New(uint16_)");
+ if (length == 0) return Empty();
if (length == -1) length = TwoByteStringLength(data);
i::Handle<i::String> result =
i::Factory::NewStringFromTwoByte(i::Vector<const uint16_t>(data, length));
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698