buffer: make indexOf(byte) faster

Add a V8 fast API implementation for indexOfNumber, which significantly
improves the performance of finding a single byte within a buffer.

Refs: https://github.com/nodejs/node/pull/52993
PR-URL: https://github.com/nodejs/node/pull/53455
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
Tobias Nießen authored and GitHub committed 2024-06-16 17:44:58 +00:00
1 parent 1aa8a785be
commit 103623b5ae
2 files changed
+54 -21

No files matched your search

+7
View File
@@ -41,6 +41,12 @@ using CFunctionCallbackWithTwoUint8ArraysFallback =
const v8::FastApiTypedArray<uint8_t>&,
const v8::FastApiTypedArray<uint8_t>&,
v8::FastApiCallbackOptions&);
using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
int32_t (*)(v8::Local<v8::Value>,
const v8::FastApiTypedArray<uint8_t>&,
uint32_t,
int64_t,
bool);
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
const uint32_t input);
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
@@ -68,6 +74,7 @@ class ExternalReferenceRegistry {
V(CFunctionCallbackWithStrings) \
V(CFunctionCallbackWithTwoUint8Arrays) \
V(CFunctionCallbackWithTwoUint8ArraysFallback) \
V(CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
V(CFunctionWithUint32) \
V(CFunctionWithDoubleReturnDouble) \
V(CFunctionWithInt64Fallback) \