buffer: default to UTF8 in byteLength()
authorTom Gallacher <tomgallacher23@gmail.com>
Tue, 24 Nov 2015 21:48:03 +0000 (21:48 +0000)
committerMyles Borins <mborins@us.ibm.com>
Tue, 19 Jan 2016 19:52:15 +0000 (11:52 -0800)
commita320045e680855d29fc3054a17e661ae74380e47
tree21ad84ab0f3c7b8157d5c8ccf02a518546920928
parentbb158f8aed8239450ea901ffa6754536b1765997
buffer: default to UTF8 in byteLength()

If an undefined encoding is passed to byteLength(),
assume that it is UTF8 immediately. This yields a
small speedup, as it prevents string operations on
the encoding argument.

PR-URL: https://github.com/nodejs/node/pull/4010
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
lib/buffer.js