From 78a4fb386b8c11d09d4a3ed764cf8edf183bef62 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 22 Dec 2009 21:56:05 -0700 Subject: [PATCH] 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. --- imp/js/DimpCore.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; + } +}); -- 2.11.0