diff --git a/benchmark/835f71a76f.txt b/benchmark/835f71a76f.txt new file mode 100644 index 0000000..8d35cd4 --- /dev/null +++ b/benchmark/835f71a76f.txt @@ -0,0 +1,17 @@ +benchmark +starting simple-query-parsing +3703 ops/sec - (100/0.027) +7299 ops/sec - (1000/0.137) +8888 ops/sec - (10000/1.125) +8733 ops/sec - (10000/1.145) +8810 ops/sec - (10000/1.135) +8771 ops/sec - (10000/1.14) +starting prepared-statement-parsing +3846 ops/sec - (100/0.026) +7299 ops/sec - (1000/0.137) +7225 ops/sec - (10000/1.384) +7288 ops/sec - (10000/1.372) +7225 ops/sec - (10000/1.384) +7457 ops/sec - (10000/1.341) +done + diff --git a/lib/connection.js b/lib/connection.js index eb42488..b8ebd79 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -474,7 +474,7 @@ Connection.prototype.parseT = function(msg) { msg.fieldCount = this.parseInt16(); var fields = []; for(var i = 0; i < msg.fieldCount; i++){ - fields[i] = this.parseField(); + fields.push(this.parseField()); } msg.fields = fields; return msg; @@ -498,7 +498,11 @@ Connection.prototype.parseD = function(msg) { var fields = []; for(var i = 0; i < fieldCount; i++) { var length = this.parseInt32(); - fields[i] = (length === -1 ? null : this.readBytes(length)); + var value = null; + if(length !== -1) { + value = this.readBytes(length); + } + fields.push(value); } msg.fieldCount = fieldCount; msg.fields = fields; @@ -553,49 +557,35 @@ Connection.prototype.parseA = function(msg) { }; Connection.prototype.parseGH = function (msg) { - msg.binary = Boolean(this.parseInt8()); + var isBinary = this.buffer[this.offset] !== 0; + this.offset++; + msg.binary = isBinary; var columnCount = this.parseInt16(); msg.columnTypes = []; for(var i = 0; i