From ed790d66d75745e57e950b0ce0e356d44188bd1f Mon Sep 17 00:00:00 2001 From: Shuvalov Anton Date: Sun, 19 Apr 2015 03:36:08 +0300 Subject: [PATCH] improove perf --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f609165..2f5b925 100644 --- a/index.js +++ b/index.js @@ -72,9 +72,11 @@ module.exports = function textr(defaults) { */ function exec(text, options) { options = clone(defaults, options); - return mws.reduce(function(text, mw) { - return mw.apply(text, [text, options]) || text; - }, text); + var l = mws.length; + for (var i = 0; i < l; i++) { + text = mws[i].apply(text, [text, options]) || text; + } + return text; } /**