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)); |