Joran,

current Rhino RegExp processing may be extremely slow. In HtmlUnit we've
customized it to use Java based RegExp processing which is far faster.
Nevertheless it's not yet good enough to fully replace Rhino RegExp
processing due to the differences between Java and JavaScript RegExp
syntax (in fact this allows to fix some of current Rhino bugs but
contains some regressions).
If you're interested, you can pick it from HtmlUnit sources and use it
in your Context.

Cheers,
Marc.
-- 
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Joran wrote:
> Hi, I would like to use Prototype's isJSON() to test for valid JSON
> strings before eval'ing them. For strings around 244kb in size, this
> is tremendously slow, around 200 seconds, shooting the process' CPU
> utilization right up to 97% from 0.1% for the same duration.
> 
> The method looks like this:
> 
> isJSON: function() {
>   var str = this;
>   if (str.blank()) return false;
>   str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
>   return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
> }
> 
> Your help would be much appreciated. Thanks in advance!
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to