Pass new buffer length to Buffer.concat (it's faster)
authorJack Allnutt <jack@allnutt.eu>
Sun, 15 Sep 2013 12:23:51 +0000 (13:23 +0100)
committerJack Allnutt <jack@allnutt.eu>
Sun, 15 Sep 2013 12:23:51 +0000 (13:23 +0100)
As per http://nodejs.org/api/buffer.html#buffer_class_method_buffer_concat_list_totallength it's faster to provide the new total length to Buffer.concat

server/irc/connection.js

index c53e169b017994dfdf1e2d24cf7a19711094347c..6e67805c5bc97cdb46b6f09dd960446fbc07f2c2 100644 (file)
@@ -651,7 +651,7 @@ var parse = function (data) {
     // If we have an incomplete line held from the previous chunk of data
     // merge it with the first line from this chunk of data
     if (this.hold_last && this.held_data !== null) {
-        bufs[0] = Buffer.concat([this.held_data, bufs[0]]);
+        bufs[0] = Buffer.concat([this.held_data, bufs[0]], this.held_data.length + bufs[0].length);
         this.hold_last = false;
         this.held_data = null;
     }