buffer: refactor all read/write functions

There are a lot of changes in this commit:

1) Remove the `noAssert` argument from all read and write functions.
2) Improve the performance of all read floating point functions
   significantly. This is done by switching to TypedArrays as the
   write floating point write functions.
3) No implicit type coercion for offset and byteLength anymore.
4) Adds a lot of tests.
5) Moves the read and write functions to the internal buffer file
   to split the files in smaller chunks.
6) Reworked a lot of existing tests.
7) Improve the performane of all all read write functions by using
   a faster input validation and by improving function logic.
8) Significantly improved the performance of all read int functions.
   This is done by using a implementation without a loop.
9) Improved error handling.
10) Rename test file to use the correct subsystem.

PR-URL: https://github.com/nodejs/node/pull/18395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Ruben Bridgewater 2018-01-30 17:34:25 +01:00
parent a6c490cc8e
commit e8bb1f35df
No known key found for this signature in database
GPG key ID: F07496B3EB3C1762
21 changed files with 2015 additions and 1839 deletions

View file

@ -42,13 +42,6 @@ assert.throws(function() {
Buffer.from(new AB());
}, TypeError);
// write{Double,Float}{LE,BE} with noAssert should not crash, cf. #3766
const b = Buffer.allocUnsafe(1);
b.writeFloatLE(11.11, 0, true);
b.writeFloatBE(11.11, 0, true);
b.writeDoubleLE(11.11, 0, true);
b.writeDoubleBE(11.11, 0, true);
// Test the byteOffset and length arguments
{
const ab = new Uint8Array(5);