Compile XML processing regular expression only once.

Requests per second from ~95 to ~98 with a "standard" test.
This commit is contained in:
Sandro Santilli 2012-09-03 15:30:31 +02:00
parent 570f55dbbd
commit b9e29938e2

View File

@ -38,7 +38,8 @@ module.exports = function(){
req.params.processXML = function(req, xml, callback) { req.params.processXML = function(req, xml, callback) {
if ( req.dbuser ) { if ( req.dbuser ) {
// Only edit XML when authenticated // Only edit XML when authenticated
xml = xml.replace(/(<Parameter name="user"><!\[CDATA\[)[^\]]*(]]><\/Parameter>)/, "$1" + req.dbuser + "$2"); if ( ! me.rx_dbuser ) me.rx_dbuser = /(<Parameter name="user"><!\[CDATA\[)[^\]]*(]]><\/Parameter>)/;
xml = xml.replace(me.rx_dbuser, "$1" + req.dbuser + "$2");
} }
callback(null, xml); callback(null, xml);
} }