From e288983197eabe45b68040815bc463a0a364938f Mon Sep 17 00:00:00 2001 From: Marcelo Gobelli Date: Wed, 30 Aug 2017 10:18:40 -0700 Subject: [PATCH] buffer: increase coverage by removing dead code buffer.js:L196 `if (value == null)` guarantees `obj != null` so L406+L418 are unnecessary. PR-URL: https://github.com/nodejs/node/pull/15100 Reviewed-By: Refael Ackermann Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/buffer.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 4cdbaa73d6..ae9ec5fc8e 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -404,17 +404,15 @@ function fromObject(obj) { return b; } - if (obj != null) { - if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) { - if (typeof obj.length !== 'number' || obj.length !== obj.length) { - return new FastBuffer(); - } - return fromArrayLike(obj); + if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) { + if (typeof obj.length !== 'number' || obj.length !== obj.length) { + return new FastBuffer(); } + return fromArrayLike(obj); + } - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data); - } + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); } }