[Pkg-javascript-commits] [backbone] 127/281: Optimize regular expressions. The capture groups aren't needed/used; the character classes will do the job just fine.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.0
in repository backbone.
commit 6ccdbb3a60c575f8dd1a672ff2b60994a8657417
Author: David Murdoch <musicisair at yahoo.com>
Date: Tue Dec 20 18:18:08 2011 -0500
Optimize regular expressions. The capture groups aren't needed/used; the character classes will do the job just fine.
Also, normalize the use of quotation-marks (change `"` to `'`' where appropriate).
---
backbone.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/backbone.js b/backbone.js
index eafa08a..f4ad577 100644
--- a/backbone.js
+++ b/backbone.js
@@ -638,8 +638,8 @@
// Cached regular expressions for matching named param parts and splatted
// parts of route strings.
- var namedParam = /:([\w\d]+)/g;
- var splatParam = /\*([\w\d]+)/g;
+ var namedParam = /:[\w\d]+/g;
+ var splatParam = /\*[\w\d]+/g;
var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
// Set up all inheritable **Backbone.Router** properties and methods.
@@ -687,9 +687,9 @@
// Convert a route string into a regular expression, suitable for matching
// against the current location hash.
_routeToRegExp : function(route) {
- route = route.replace(escapeRegExp, "\\$&")
- .replace(namedParam, "([^\/]*)")
- .replace(splatParam, "(.*?)");
+ route = route.replace(escapeRegExp, '\\$&')
+ .replace(namedParam, '([^\/]*)')
+ .replace(splatParam, '(.*?)');
return new RegExp('^' + route + '$');
},
@@ -855,7 +855,7 @@
// a new one to the browser history.
_updateHash: function(location, fragment, replace) {
if (replace) {
- location.replace(location.toString().replace(/(javascript:|#).*$/, "") + "#" + fragment);
+ location.replace(location.toString().replace(/(javascript:|#).*$/, '') + '#' + fragment);
} else {
location.hash = fragment;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list