Skip to content

Commit fb477ff

Browse files
committed
squash! lint
1 parent af5b1f1 commit fb477ff

2 files changed

Lines changed: 31 additions & 10 deletions

File tree

lib/internal/webstreams/util.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ const {
44
ArrayPrototypePush,
55
ArrayPrototypeShift,
66
AsyncIteratorPrototype,
7+
FunctionPrototypeCall,
78
MathMax,
89
NumberIsNaN,
910
PromisePrototypeThen,
1011
PromiseReject,
1112
PromiseResolve,
12-
ReflectGet,
13-
ReflectApply,
1413
Symbol,
1514
} = primordials;
1615

@@ -147,9 +146,25 @@ function enqueueValueWithSize(controller, value, size) {
147146
controller[kState].queueTotalSize += size;
148147
}
149148

150-
function createPromiseCallback(name, fn, thisArg) {
149+
// Arity-specialized variants of the promise-callback wrapper. The generic
150+
// rest-parameter + ReflectApply form allocated an arguments array on every
151+
// invocation; these run on per-chunk hot paths (pull/write/transform), so
152+
// each known call-site arity gets its own wrapper. The exact number of
153+
// arguments passed through to the user callback is observable and must be
154+
// preserved.
155+
function createPromiseCallbackNoParams(name, fn, thisArg) {
151156
validateFunction(fn, name);
152-
return async (...args) => ReflectApply(fn, thisArg, args);
157+
return async () => FunctionPrototypeCall(fn, thisArg);
158+
}
159+
160+
function createPromiseCallback1Param(name, fn, thisArg) {
161+
validateFunction(fn, name);
162+
return async (arg) => FunctionPrototypeCall(fn, thisArg, arg);
163+
}
164+
165+
function createPromiseCallback2Params(name, fn, thisArg) {
166+
validateFunction(fn, name);
167+
return async (arg1, arg2) => FunctionPrototypeCall(fn, thisArg, arg1, arg2);
153168
}
154169

155170
function isPromisePending(promise) {
@@ -208,7 +223,9 @@ module.exports = {
208223
canCopyArrayBuffer,
209224
cloneAsUint8Array,
210225
copyArrayBuffer,
211-
createPromiseCallback,
226+
createPromiseCallbackNoParams,
227+
createPromiseCallback1Param,
228+
createPromiseCallback2Params,
212229
customInspect,
213230
defaultSizeAlgorithm,
214231
dequeueValue,

src/node_buffer.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,11 +1584,15 @@ void CopyArrayBuffer(const FunctionCallbackInfo<Value>& args) {
15841584

15851585
CHECK_LE(destination_offset, static_cast<uint64_t>(destination_byte_length));
15861586
CHECK_LE(source_offset, static_cast<uint64_t>(source_byte_length));
1587-
CHECK_LE(bytes_to_copy, static_cast<uint64_t>(destination_byte_length) - destination_offset);
1588-
CHECK_LE(bytes_to_copy, static_cast<uint64_t>(source_byte_length) - source_offset);
1589-
1590-
uint8_t* dest = static_cast<uint8_t*>(destination) + static_cast<size_t>(destination_offset);
1591-
uint8_t* src = static_cast<uint8_t*>(source) + static_cast<size_t>(source_offset);
1587+
CHECK_LE(bytes_to_copy,
1588+
static_cast<uint64_t>(destination_byte_length) - destination_offset);
1589+
CHECK_LE(bytes_to_copy,
1590+
static_cast<uint64_t>(source_byte_length) - source_offset);
1591+
1592+
uint8_t* dest = static_cast<uint8_t*>(destination) +
1593+
static_cast<size_t>(destination_offset);
1594+
uint8_t* src =
1595+
static_cast<uint8_t*>(source) + static_cast<size_t>(source_offset);
15921596
memcpy(dest, src, static_cast<size_t>(bytes_to_copy));
15931597
}
15941598

0 commit comments

Comments
 (0)