#7587 - $.parseJSON huge performance optimization by skipping regex#98
#7587 - $.parseJSON huge performance optimization by skipping regex#980 commit merged intojquery:masterfrom
Conversation
|
jay, can you do a jsperf test on this |
|
The test was still there because Chrome's JSON parser was too lenient, IIRC. Have they fixed it? |
|
in Opera 9.64 this breaks. |
|
Is there a unit test or example of the issue in chrome? |
|
I've updated the jsperf test to fix an issue with scope on older browsers that had trouble with the way I patched in the new parseJSON function. (the patch remains the same, I merely declared the variables that could be conflicted). Could you try Opera again? |
|
Sorry, new url is http://jsperf.com/parsejson-optimization/2 |
|
the fixed version works in Opera 9.64 |
|
I’ve created a ticket on Trac for this issue, #7587. FWIW, my own real-world applications have this optimization in place already because JSON parsing of long strings was taking upwards of 15 seconds; without the regexp, it takes less than 1 second. |
this checking skips the expensive regex/replace validation on the JSON when using the browser's native JSON parser because the threat to security is gone. My tests show this reduces the runtime of the parseJSON function to 1/3rd of the original code.
#7587