A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/f373d6a540 below:

use WriteOneByteV2 in napi_get_value_string_latin1 · nodejs/node@f373d6a · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+12

-12

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+12

-12

lines changed Original file line number Diff line number Diff line change

@@ -2441,21 +2441,21 @@ napi_status NAPI_CDECL napi_get_value_string_latin1(

2441 2441 2442 2442

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);

2443 2443

RETURN_STATUS_IF_FALSE(env, val->IsString(), napi_string_expected);

2444 +

v8::Local<v8::String> str = val.As<v8::String>();

2444 2445 2445 2446

if (!buf) {

2446 2447

CHECK_ARG(env, result);

2447 -

*result = val.As<v8::String>()->Length();

2448 +

*result = str->Length();

2448 2449

} else if (bufsize != 0) {

2449 -

int copied =

2450 -

val.As<v8::String>()->WriteOneByte(env->isolate,

2451 -

reinterpret_cast<uint8_t*>(buf),

2452 -

0,

2453 -

bufsize - 1,

2454 -

v8::String::NO_NULL_TERMINATION);

2455 - 2456 -

buf[copied] = '\0';

2450 +

uint32_t length = static_cast<uint32_t>(

2451 +

std::min(bufsize - 1, static_cast<size_t>(str->Length())));

2452 +

str->WriteOneByteV2(env->isolate,

2453 +

0,

2454 +

length,

2455 +

reinterpret_cast<uint8_t*>(buf),

2456 +

v8::String::WriteFlags::kNullTerminate);

2457 2457

if (result != nullptr) {

2458 -

*result = copied;

2458 +

*result = length;

2459 2459

}

2460 2460

} else if (result != nullptr) {

2461 2461

*result = 0;

@@ -2479,12 +2479,12 @@ napi_status NAPI_CDECL napi_get_value_string_utf8(

2479 2479 2480 2480

v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value);

2481 2481

RETURN_STATUS_IF_FALSE(env, val->IsString(), napi_string_expected);

2482 +

v8::Local<v8::String> str = val.As<v8::String>();

2482 2483 2483 2484

if (!buf) {

2484 2485

CHECK_ARG(env, result);

2485 -

*result = val.As<v8::String>()->Utf8LengthV2(env->isolate);

2486 +

*result = str->Utf8LengthV2(env->isolate);

2486 2487

} else if (bufsize != 0) {

2487 -

auto str = val.As<v8::String>();

2488 2488

size_t copied =

2489 2489

str->WriteUtf8V2(env->isolate,

2490 2490

buf,

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4