From a8f9b7dc93e4222fcd7172be785bfeeb560a432f Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Wed, 21 May 2014 00:44:53 +1000 Subject: [PATCH] avoid eval if the row is returned as an array --- lib/result.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/result.js b/lib/result.js index f6c33cc..ae99255 100644 --- a/lib/result.js +++ b/lib/result.js @@ -11,7 +11,8 @@ var Result = function(rowMode) { this.fields = []; this._parsers = []; this.RowCtor = null; - if(rowMode == "array") { + this.rowAsArray = rowMode == "array"; + if(this.rowAsArray) { this.parseRow = this._parseRowAsArray; } }; @@ -93,7 +94,9 @@ Result.prototype.addFields = function(fieldDescriptions) { //results in ~60% speedup on large query result sets ctorBody += inlineParser(desc.name, i); } - this.RowCtor = Function("parsers", "rowData", ctorBody); + if(!this.rowAsArray) { + this.RowCtor = Function("parsers", "rowData", ctorBody); + } }; module.exports = Result;