Created
December 6, 2009 00:40
-
-
Save aarongustafson/249946 to your computer and use it in GitHub Desktop.
Regexp performance is faster when you "precompile" (examples from JavaScript Performance Rocks!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function directPassing ( string ) | |
| { | |
| return string.match( /abc/ ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var REGEXP = /abc/; | |
| function variablePassing( string ) | |
| { | |
| return string.match( REGEXP ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment