Much more efficient unfilterJSON() implementation.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 04:56:05 +0000 (21:56 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 05:13:19 +0000 (22:13 -0700)
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

index a463f1e..4a180a4 100644 (file)
@@ -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;
+    }
+});