Skip to content

Commit

Permalink
Remove more uses of deprecated type f8::FastApiTypedArray
Browse files Browse the repository at this point in the history
Follow-up of #197
  • Loading branch information
pthier authored and victorgomes committed Nov 18, 2024
1 parent 7449980 commit ba764ed
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ int32_t IndexOfNumber(const uint8_t* buffer_data,
return ptr != nullptr ? static_cast<int32_t>(ptr_uint8 - buffer_data) : -1;
}

void SlowIndexOfNumber(const FunctionCallbackInfo<Value>& args) {
void IndexOfNumber(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsUint32());
CHECK(args[2]->IsNumber());
CHECK(args[3]->IsBoolean());
Expand All @@ -1123,20 +1123,6 @@ void SlowIndexOfNumber(const FunctionCallbackInfo<Value>& args) {
buffer.data(), buffer.length(), needle, offset_i64, is_forward));
}

int32_t FastIndexOfNumber(v8::Local<v8::Value>,
const FastApiTypedArray<uint8_t>& buffer,
uint32_t needle,
int64_t offset_i64,
bool is_forward) {
uint8_t* buffer_data;
CHECK(buffer.getStorageIfAligned(&buffer_data));
return IndexOfNumber(
buffer_data, buffer.length(), needle, offset_i64, is_forward);
}

static v8::CFunction fast_index_of_number(
v8::CFunction::Make(FastIndexOfNumber));

void Swap16(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
Expand Down Expand Up @@ -1530,11 +1516,7 @@ void Initialize(Local<Object> target,
SetMethodNoSideEffect(context, target, "compareOffset", CompareOffset);
SetMethod(context, target, "fill", Fill);
SetMethodNoSideEffect(context, target, "indexOfBuffer", IndexOfBuffer);
SetFastMethodNoSideEffect(context,
target,
"indexOfNumber",
SlowIndexOfNumber,
&fast_index_of_number);
SetMethodNoSideEffect(context, target, "indexOfNumber", IndexOfNumber);
SetMethodNoSideEffect(context, target, "indexOfString", IndexOfString);

SetMethod(context, target, "detachArrayBuffer", DetachArrayBuffer);
Expand Down Expand Up @@ -1607,9 +1589,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(CompareOffset);
registry->Register(Fill);
registry->Register(IndexOfBuffer);
registry->Register(SlowIndexOfNumber);
registry->Register(FastIndexOfNumber);
registry->Register(fast_index_of_number.GetTypeInfo());
registry->Register(IndexOfNumber);
registry->Register(IndexOfString);

registry->Register(Swap16);
Expand Down

0 comments on commit ba764ed

Please sign in to comment.