diff options
author | Daniel Ennis <aikar@aikar.co> | 2011-10-11 20:54:55 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-12 15:06:51 -0700 |
commit | 59be97532269a208f0121060772528690a63677b (patch) | |
tree | e350bb71f834bb8b96f6ab45fd5bb835c4d7175b /lib | |
parent | 73b4b86d29ada97e95198307412bd153a3f79a06 (diff) | |
download | android-node-v8-59be97532269a208f0121060772528690a63677b.tar.gz android-node-v8-59be97532269a208f0121060772528690a63677b.tar.bz2 android-node-v8-59be97532269a208f0121060772528690a63677b.zip |
Improve IPC performance.
Reading of JSON data off the buffer, 10-15% performance increase.
Fixes #1864.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/child_process.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/child_process.js b/lib/child_process.js index f2a1a7fdd1..2c4921c733 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -77,14 +77,15 @@ function setupChannel(target, channel) { if (pool) { jsonBuffer += pool.toString('ascii', offset, offset + length); - var i; - while ((i = jsonBuffer.indexOf('\n')) >= 0) { - var json = jsonBuffer.slice(0, i); + var i, start = 0; + while ((i = jsonBuffer.indexOf('\n', start)) >= 0) { + var json = jsonBuffer.slice(start, i); var message = JSON.parse(json); - jsonBuffer = jsonBuffer.slice(i + 1); target.emit('message', message, recvHandle); + start = i+1; } + jsonBuffer = jsonBuffer.slice(start); } else { channel.close(); |