lib: avoid .toLowerCase() call in Buffer#write()
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 4 Mar 2015 00:09:33 +0000 (01:09 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 5 Mar 2015 18:44:50 +0000 (19:44 +0100)
commit4ddd6406ce1c474e1a54a5aa9b56f7554902fd10
treedc60f168c3e885d1d91411c1770dac2e24845dbe
parentbbf54a554ababa91ced243acb0d2721bc19eb1dc
lib: avoid .toLowerCase() call in Buffer#write()

Avoid a costly String#toLowerCase() call in Buffer#write() in the
common case, i.e., that the string is already lowercase.  Reduces
the running time of the following benchmark by about 40%:

    for (var b = Buffer(1), i = 0; i < 25e6; ++i) b.write('x', 'ucs2');

PR-URL: https://github.com/iojs/io.js/pull/1048
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
lib/buffer.js