Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efa142c

Browse filesBrowse files
avivkellerRafaelGSS
authored andcommitted
src: migrate String::Value to String::ValueView
Fixes #54417 Ref: #55452 PR-URL: #55458 Refs: #55452 Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f92f20b commit efa142c
Copy full SHA for efa142c

File tree

Expand file treeCollapse file tree

3 files changed

+25
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-28
lines changed
Open diff view settings
Collapse file

‎src/inspector_js_api.cc‎

Copy file name to clipboardExpand all lines: src/inspector_js_api.cc
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) {
245245
Environment* env = Environment::GetCurrent(args);
246246

247247
CHECK(args[0]->IsString());
248-
Local<String> task_name = args[0].As<String>();
249-
String::Value task_name_value(args.GetIsolate(), task_name);
250-
StringView task_name_view(*task_name_value, task_name_value.length());
248+
249+
TwoByteValue task_name_buffer(args.GetIsolate(), args[0]);
250+
StringView task_name_view(*task_name_buffer, task_name_buffer.length());
251251

252252
CHECK(args[1]->IsNumber());
253253
int64_t task_id = args[1]->IntegerValue(env->context()).FromJust();
Collapse file

‎src/node_buffer.cc‎

Copy file name to clipboardExpand all lines: src/node_buffer.cc
+12-15Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,9 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
965965
size_t result = haystack_length;
966966

967967
if (enc == UCS2) {
968-
String::Value needle_value(isolate, needle);
969-
if (*needle_value == nullptr)
970-
return args.GetReturnValue().Set(-1);
968+
TwoByteValue needle_buffer(isolate, needle);
971969

972-
if (haystack_length < 2 || needle_value.length() < 1) {
970+
if (haystack_length < 2 || needle_buffer.length() < 1) {
973971
return args.GetReturnValue().Set(-1);
974972
}
975973

@@ -989,13 +987,12 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
989987
offset / 2,
990988
is_forward);
991989
} else {
992-
result =
993-
nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack),
994-
haystack_length / 2,
995-
reinterpret_cast<const uint16_t*>(*needle_value),
996-
needle_value.length(),
997-
offset / 2,
998-
is_forward);
990+
result = nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack),
991+
haystack_length / 2,
992+
needle_buffer.out(),
993+
needle_buffer.length(),
994+
offset / 2,
995+
is_forward);
999996
}
1000997
result *= 2;
1001998
} else if (enc == UTF8) {
@@ -1295,10 +1292,10 @@ static void Btoa(const FunctionCallbackInfo<Value>& args) {
12951292
input->Length(),
12961293
buffer.out());
12971294
} else {
1298-
String::Value value(env->isolate(), input);
1295+
String::ValueView value(env->isolate(), input);
12991296
MaybeStackBuffer<char> stack_buf(value.length());
13001297
size_t out_len = simdutf::convert_utf16_to_latin1(
1301-
reinterpret_cast<const char16_t*>(*value),
1298+
reinterpret_cast<const char16_t*>(value.data16()),
13021299
value.length(),
13031300
stack_buf.out());
13041301
if (out_len == 0) { // error
@@ -1355,8 +1352,8 @@ static void Atob(const FunctionCallbackInfo<Value>& args) {
13551352
buffer.SetLength(expected_length);
13561353
result = simdutf::base64_to_binary(data, input->Length(), buffer.out());
13571354
} else { // 16-bit case
1358-
String::Value value(env->isolate(), input);
1359-
auto data = reinterpret_cast<const char16_t*>(*value);
1355+
String::ValueView value(env->isolate(), input);
1356+
auto data = reinterpret_cast<const char16_t*>(value.data16());
13601357
size_t expected_length =
13611358
simdutf::maximal_binary_length_from_base64(data, value.length());
13621359
buffer.AllocateSufficientStorage(expected_length);
Collapse file

‎src/string_bytes.cc‎

Copy file name to clipboardExpand all lines: src/string_bytes.cc
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,10 @@ size_t StringBytes::Write(Isolate* isolate,
305305
input_view.length());
306306
}
307307
} else {
308-
String::Value value(isolate, str);
309308
size_t written_len = buflen;
310309
auto result = simdutf::base64_to_binary_safe(
311-
reinterpret_cast<const char16_t*>(*value),
312-
value.length(),
310+
reinterpret_cast<const char16_t*>(input_view.data16()),
311+
input_view.length(),
313312
buf,
314313
written_len,
315314
simdutf::base64_url);
@@ -319,7 +318,8 @@ size_t StringBytes::Write(Isolate* isolate,
319318
// The input does not follow the WHATWG forgiving-base64 specification
320319
// (adapted for base64url with + and / replaced by - and _).
321320
// https://infra.spec.whatwg.org/#forgiving-base64-decode
322-
nbytes = nbytes::Base64Decode(buf, buflen, *value, value.length());
321+
nbytes = nbytes::Base64Decode(
322+
buf, buflen, input_view.data16(), input_view.length());
323323
}
324324
}
325325
break;
@@ -344,19 +344,19 @@ size_t StringBytes::Write(Isolate* isolate,
344344
input_view.length());
345345
}
346346
} else {
347-
String::Value value(isolate, str);
348347
size_t written_len = buflen;
349348
auto result = simdutf::base64_to_binary_safe(
350-
reinterpret_cast<const char16_t*>(*value),
351-
value.length(),
349+
reinterpret_cast<const char16_t*>(input_view.data16()),
350+
input_view.length(),
352351
buf,
353352
written_len);
354353
if (result.error == simdutf::error_code::SUCCESS) {
355354
nbytes = written_len;
356355
} else {
357356
// The input does not follow the WHATWG base64 specification
358357
// https://infra.spec.whatwg.org/#forgiving-base64-decode
359-
nbytes = nbytes::Base64Decode(buf, buflen, *value, value.length());
358+
nbytes = nbytes::Base64Decode(
359+
buf, buflen, input_view.data16(), input_view.length());
360360
}
361361
}
362362
break;
@@ -369,8 +369,8 @@ size_t StringBytes::Write(Isolate* isolate,
369369
reinterpret_cast<const char*>(input_view.data8()),
370370
input_view.length());
371371
} else {
372-
String::Value value(isolate, str);
373-
nbytes = nbytes::HexDecode(buf, buflen, *value, value.length());
372+
String::ValueView value(isolate, str);
373+
nbytes = nbytes::HexDecode(buf, buflen, value.data8(), value.length());
374374
}
375375
break;
376376

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.