Skip to content

Commit 00c86cc

Browse files
authored
buffer: remove Uint8Array check
This makes write[U]Int* operations on Buffer with `noAssert=false` about 3 times faster. PR-URL: #11324 Refs: #11245 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent bd07c8f commit 00c86cc

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/buffer.js

-2
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,6 @@ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
10561056

10571057

10581058
function checkInt(buffer, value, offset, ext, max, min) {
1059-
if (!isUint8Array(buffer))
1060-
throw new TypeError('"buffer" argument must be a Buffer or Uint8Array');
10611059
if (value > max || value < min)
10621060
throw new TypeError('"value" argument is out of bounds');
10631061
if (offset + ext > buffer.length)

test/parallel/test-buffer-write-noassert.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ function write(funx, args, result, res) {
2020
);
2121
}
2222

23-
{
24-
const error = /Int/.test(funx) ?
25-
/^TypeError: "buffer" argument must be a Buffer or Uint8Array$/ :
26-
/^TypeError: argument should be a Buffer$/;
27-
23+
if (!/Int/.test(funx)) {
2824
assert.throws(
2925
() => Buffer.alloc(9)[funx].apply(new Uint32Array(1), args),
30-
error
26+
/^TypeError: argument should be a Buffer$/
3127
);
3228
}
3329

0 commit comments

Comments
 (0)