diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-09-06 03:07:32 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-09-09 11:03:49 -0700 |
commit | 5506f99dfaba02fdc2f389ad3c1ebea19dca12dd (patch) | |
tree | 8aec2a7a3ae98c96e262bf615d97f05925481250 /lib/buffer.js | |
parent | ececd92f62782af3ec82fe7f9132f971d173905f (diff) | |
download | nodejs-5506f99dfaba02fdc2f389ad3c1ebea19dca12dd.tar.gz nodejs-5506f99dfaba02fdc2f389ad3c1ebea19dca12dd.tar.bz2 nodejs-5506f99dfaba02fdc2f389ad3c1ebea19dca12dd.zip |
map charsWritten to fast buffer
Diffstat (limited to 'lib/buffer.js')
-rw-r--r-- | lib/buffer.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/buffer.js b/lib/buffer.js index 2a4775c17..5d1826873 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -211,23 +211,33 @@ Buffer.prototype.write = function write (string, offset, encoding) { // Make sure we are not going to overflow var maxLength = this.length - offset; + var ret; switch (encoding) { case 'utf8': case 'utf-8': - return this.parent.utf8Write(string, this.offset + offset, maxLength); + ret = this.parent.utf8Write(string, this.offset + offset, maxLength); + break; case 'ascii': - return this.parent.asciiWrite(string, this.offset + offset, maxLength); + ret = this.parent.asciiWrite(string, this.offset + offset, maxLength); + break; case 'binary': - return this.parent.binaryWrite(string, this.offset + offset, maxLength); + ret = this.parent.binaryWrite(string, this.offset + offset, maxLength); + break; case 'base64': - return this.parent.base64Write(string, this.offset + offset, maxLength); + // Warning: maxLength not taken into account in base64Write + ret = this.parent.base64Write(string, this.offset + offset, maxLength); + break; default: throw new Error('Unknown encoding'); } + + Buffer._charsWritten = SlowBuffer._charsWritten; + + return ret; }; |