Chromium Code Reviews| Index: Source/bindings/core/v8/V8Binding.h |
| diff --git a/Source/bindings/core/v8/V8Binding.h b/Source/bindings/core/v8/V8Binding.h |
| index 6e4b772d205aaba6b7fc31c45792855d8aa71d17..5118d741034f2545b91dddeeeee01b46e29b261d 100644 |
| --- a/Source/bindings/core/v8/V8Binding.h |
| +++ b/Source/bindings/core/v8/V8Binding.h |
| @@ -347,16 +347,22 @@ inline v8::Handle<v8::String> v8String(v8::Isolate* isolate, const String& strin |
| return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(string.impl(), isolate); |
| } |
| -inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str) |
|
bashi
2015/03/20 08:16:44
I think we can remove this. When length is -1, v8:
|
| +inline v8::Local<v8::String> v8NormalString(v8::Isolate* isolate, const char* str, int length = -1) |
| { |
| ASSERT(isolate); |
| - return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, strlen(str)); |
| + v8::Local<v8::String> value; |
| + if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal, length).ToLocal(&value))) |
|
bashi
2015/03/20 08:16:44
I added LIKELY() because according to the v8.h, Ne
haraken
2015/03/20 09:46:08
v8NormalString is performance-sensitive, so LIKELY
|
| + return value; |
| + return v8::String::Empty(isolate); |
| } |
| -inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str, size_t length) |
| +inline v8::Handle<v8::String> v8AtomicString(v8::Isolate* isolate, const char* str, int length = -1) |
| { |
| ASSERT(isolate); |
| - return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString, length); |
| + v8::Local<v8::String> value; |
| + if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInternalized, length).ToLocal(&value))) |
| + return value; |
| + return v8::String::Empty(isolate); |
| } |
| inline v8::Handle<v8::Value> v8Undefined() |