Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fixup! src: migrate String::Value to String::ValueView
  • Loading branch information
avivkeller committed Oct 19, 2024
commit f2ed23b666a34b9f1256bc1ffe3dc70820c50102
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()) {
Comment thread
avivkeller marked this conversation as resolved.
Outdated
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