diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-09-01 01:45:24 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-09-01 01:45:24 +0300 |
commit | d43bef4d97afe0bdbef188be702087bc518b8ccc (patch) | |
tree | 76c100b94da170572e38064d0348e901bb28452b /plugins/Morpheus | |
parent | 28a4785316471acd3ef96460e329a77426d2bf9b (diff) |
Override string trim only if needed to fix performance issue (#13371)
I had a case where this method took 90s to execute compared to builtin only a ms.
Diffstat (limited to 'plugins/Morpheus')
-rw-r--r-- | plugins/Morpheus/javascripts/piwikHelper.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/plugins/Morpheus/javascripts/piwikHelper.js b/plugins/Morpheus/javascripts/piwikHelper.js index 685c967d46..341622bdb6 100644 --- a/plugins/Morpheus/javascripts/piwikHelper.js +++ b/plugins/Morpheus/javascripts/piwikHelper.js @@ -567,11 +567,11 @@ var piwikHelper = { } } }; - -String.prototype.trim = function() { - return this.replace(/^\s+|\s+$/g,""); -}; - +if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g,""); + }; +} /** * Returns true if the event keypress passed in parameter is the ENTER key * @param {Event} e current window event |