Skip to content

Commit

Permalink
fixup! fixup! src: migrate String::Value to String::ValueView
Browse files Browse the repository at this point in the history
  • Loading branch information
avivkeller committed Oct 19, 2024
1 parent b0501f5 commit f2ed23b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,9 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

CHECK(args[0]->IsString());
Local<String> task_name = args[0].As<String>();

std::vector<uint16_t> task_name_buffer(task_name->Length());
task_name->Write(
env->isolate(), task_name_buffer.data(), 0, task_name->Length());
StringView task_name_view(task_name_buffer.data(), task_name_buffer.size());
TwoByteValue task_name_buffer(args.GetIsolate(), args[0]);
StringView task_name_view(*task_name_buffer, task_name_buffer.length());

CHECK(args[1]->IsNumber());
int64_t task_id = args[1]->IntegerValue(env->context()).FromJust();
Expand Down
9 changes: 4 additions & 5 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,9 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
size_t result = haystack_length;

if (enc == UCS2) {
uint16_t* needle_buffer = new uint16_t[needle->Length()];
int needle_length = needle->Write(isolate, needle_buffer);
TwoByteValue needle_buffer(isolate, needle);

if (haystack_length < 2 || needle_length < 1) {
if (haystack_length < 2 || needle_buffer.length()) {
return args.GetReturnValue().Set(-1);
}

Expand All @@ -990,8 +989,8 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
} else {
result = nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack),
haystack_length / 2,
needle_buffer,
needle_length,
needle_buffer.out(),
needle_buffer.length(),
offset / 2,
is_forward);
}
Expand Down

0 comments on commit f2ed23b

Please sign in to comment.