diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-01 22:35:57 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-01 23:07:17 +0100 |
commit | 3f65916fa995c74b0db2064911fe76d18d3509b6 (patch) | |
tree | 0b30aa4256cf1e3326da28bf8c87a040b1cd343a /src/node_buffer.h | |
parent | c7c1ed01ae1798ed75e1c0733748c0d2d5239dd5 (diff) | |
download | node-new-3f65916fa995c74b0db2064911fe76d18d3509b6.tar.gz |
buffer: optimize Buffer.prototype.toString('hex')
Move the implementation to C++ land. The old JS implementation used
string concatenation, was dog slow and consumed copious amounts of
memory for large buffers. Example:
var buf = Buffer(0x1000000); // 16 MB
buf.toString('hex') // Used 3+ GB of memory.
The new implementation operates in O(n) time and space.
Fixes #4700.
Diffstat (limited to 'src/node_buffer.h')
-rw-r--r-- | src/node_buffer.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h index 48d0dd2727..27991fcfc0 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -118,6 +118,7 @@ class NODE_EXTERN Buffer: public ObjectWrap { static v8::Handle<v8::Value> Base64Slice(const v8::Arguments &args); static v8::Handle<v8::Value> Utf8Slice(const v8::Arguments &args); static v8::Handle<v8::Value> Ucs2Slice(const v8::Arguments &args); + static v8::Handle<v8::Value> HexSlice(const v8::Arguments &args); static v8::Handle<v8::Value> BinaryWrite(const v8::Arguments &args); static v8::Handle<v8::Value> Base64Write(const v8::Arguments &args); static v8::Handle<v8::Value> AsciiWrite(const v8::Arguments &args); |