Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
buffer: remove unreachable code
46f202 introduced changes that cause a previously reachable error
condition to be unreachable. Remove the code.

The error condition checks that `byteLength()` doesn't return -1. But
that will only happen if `byteLength()` receives an encoding that is
falsy. However the call to `byteLength()` is in an `else` block that is
only reachable if `encoding` is a string with a length greater than 0.
So `byteLength()` will never return `-1` in this situation.
  • Loading branch information
Trott committed Apr 16, 2017
commit e5d04e31fb5c2ae4c2a4fd48d80161556956d434
2 changes: 0 additions & 2 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ function fromString(string, encoding) {
length = binding.byteLengthUtf8(string);
} else {
length = byteLength(string, encoding, true);
if (length === -1)
throw new TypeError('"encoding" must be a valid string encoding');
if (string.length === 0)
return new FastBuffer();
}
Expand Down