diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 1df6879a6a..7b07c6b7da 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -754,21 +754,17 @@ Local StringBytes::Encode(Isolate* isolate, Local StringBytes::Encode(Isolate* isolate, const uint16_t* buf, size_t buflen) { - const uint16_t* src = buf; - Local val; + if (buflen < EXTERN_APEX) { val = String::NewFromTwoByte(isolate, - src, + buf, String::kNormalString, buflen); } else { - val = ExternTwoByteString::NewFromCopy(isolate, src, buflen); + val = ExternTwoByteString::NewFromCopy(isolate, buf, buflen); } - if (src != buf) - delete[] src; - return val; }