[
https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678925#action_12678925
]
kan.izh edited comment on WICKET-2127 at 3/4/09 1:16 PM:
--------------------------------------------------------------------
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g
modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker +
m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
was (Author: kan.izh):
I am not sure what do you want to do, but you can use RegExp object, so
this:
[code]
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
[/code]
But my advice, don't do generic method replaceAll, but use replace with g
modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker +
m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my
> pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is
> responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much
> faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.