From 440da3dd4cb49108f8e21c7dd63ab631e6eedd9b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 14 Feb 2018 23:42:57 +0100 Subject: [PATCH 1/5] buffer: improve Buffer#fill performance 1) This improves the performance for Buffer#fill by using shortcuts. 2) It also ports throwing errors to JS. That way they contain the proper error code. 3) Using negative `end` values will from now on result in an error instead of just doing nothing. 4) Passing in `null` as encoding is from now on accepted as 'utf8'. --- doc/api/buffer.md | 3 + lib/buffer.js | 88 +++++++++-------- lib/internal/util.js | 2 +- src/node_buffer.cc | 17 ++-- test/parallel/test-buffer-fill.js | 98 ++++--------------- .../test-internal-util-normalizeencoding.js | 13 ++- 6 files changed, 85 insertions(+), 136 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 82628156bf31eb..0a97d194065421 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1205,6 +1205,9 @@ console.log(buf1.equals(buf3));