From: Michael M Slusarz Date: Wed, 23 Dec 2009 04:56:05 +0000 (-0700) Subject: Much more efficient unfilterJSON() implementation. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=78a4fb386b8c11d09d4a3ed764cf8edf183bef62;p=horde.git Much more efficient unfilterJSON() implementation. Large text messages (e.g. 900 KB message for the horde cvs -> git import) was crashing on FF 3 due to a stack size issue. The prototypejs code is using a matching regex to store the entire data part of the JSON payload. No reason to do that - much more efficient to use string-based functions to match the front and rear of the string. --- diff --git a/imp/js/DimpCore.js b/imp/js/DimpCore.js index a463f1ec0..4a180a473 100644 --- a/imp/js/DimpCore.js +++ b/imp/js/DimpCore.js @@ -527,3 +527,16 @@ var DimpCore = { } }; + +/* More efficient String.unfilterJSON() function. */ +Object.extend(String.prototype, { + unfilterJSON: function(filter) { + if (filter) { + return this.replace(filter, '$1'); + } else if (this.startsWith('/*-secure-') && + this.endsWith('*/')) { + return this.slice(10, -2); + } + return this; + } +});