From b9e29938e2804d30750d450ce2b5d73ab8e307f6 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 3 Sep 2012 15:30:31 +0200 Subject: [PATCH] Compile XML processing regular expression only once. Requests per second from ~95 to ~98 with a "standard" test. --- lib/cartodb/server_options.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 76447bc5..5c25c3f5 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -38,7 +38,8 @@ module.exports = function(){ req.params.processXML = function(req, xml, callback) { if ( req.dbuser ) { // Only edit XML when authenticated - xml = xml.replace(/(<\/Parameter>)/, "$1" + req.dbuser + "$2"); + if ( ! me.rx_dbuser ) me.rx_dbuser = /(<\/Parameter>)/; + xml = xml.replace(me.rx_dbuser, "$1" + req.dbuser + "$2"); } callback(null, xml); }