Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Apr 10, 2015
1 parent 475decc commit 51b5e5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var Router = (function () {

this.insert(method, path.substring(0, i), null, PNODE);
// `/`
for (; i < l && path.charCodeAt(i) !== 47; i++) {}
for (; i < l && path.charCodeAt(i) !== 47; ++i) {}

// new param key `$n`
var param = '$' + count;
Expand Down Expand Up @@ -172,9 +172,9 @@ var Router = (function () {
if (search.length === 0 || search === cn.prefix) {
result[0] = cn.handler;
if (cn.handler && cn.handler.keys) {
cn.handler.keys.forEach(function (a, i) {
params[i].name = a;
});
for (var i = 0, _l = cn.handler.keys.length; i < _l; ++i) {
params[i].name = cn.handler.keys[i];
}
}
return result;
}
Expand All @@ -185,13 +185,13 @@ var Router = (function () {
search = search.substring(l);
}

for (var i = 0, k = cn.edges.length, e = undefined; i < k; i++) {
for (var i = 0, k = cn.edges.length, e = undefined; i < k; ++i) {
e = cn.edges[i];
var has = e.label === 58 ? PNODE : e.label === 42 ? CNODE : 0;
if (has === PNODE) {
l = search.length;
// `/`
for (var j = 0; j < l && search.charCodeAt(j) !== 47; j++) {}
for (var j = 0; j < l && search.charCodeAt(j) !== 47; ++j) {}

params[n] = {
name: e.prefix.substring(1),
Expand Down Expand Up @@ -227,7 +227,7 @@ var Router = (function () {
function lcp(a, b) {
var i = 0;
var max = Math.min(a.length, b.length);
for (; i < max && a.charCodeAt(i) === b.charCodeAt(i); i++) {}
for (; i < max && a.charCodeAt(i) === b.charCodeAt(i); ++i) {}
return i;
}

Expand Down
14 changes: 7 additions & 7 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Router {

this.insert(method, path.substring(0, i), null, PNODE);
// `/`
for (; i < l && (path.charCodeAt(i) !== 47); i++) {}
for (; i < l && (path.charCodeAt(i) !== 47); ++i) {}

// new param key `$n`
let param = '$' + count;
Expand Down Expand Up @@ -163,9 +163,9 @@ class Router {
if (search.length === 0 || search === cn.prefix) {
result[0] = cn.handler;
if (cn.handler && cn.handler.keys) {
cn.handler.keys.forEach((a, i) => {
params[i].name = a;
});
for (let i = 0, l = cn.handler.keys.length; i < l; ++i) {
params[i].name = cn.handler.keys[i];
}
}
return result;
}
Expand All @@ -176,13 +176,13 @@ class Router {
search = search.substring(l);
}

for (let i = 0, k = cn.edges.length, e; i < k; i++) {
for (let i = 0, k = cn.edges.length, e; i < k; ++i) {
e = cn.edges[i];
let has = e.label === 58 ? PNODE : (e.label === 42 ? CNODE : 0);
if (has === PNODE) {
l = search.length;
// `/`
for (var j = 0; j < l && (search.charCodeAt(j) !== 47); j++) {}
for (var j = 0; j < l && (search.charCodeAt(j) !== 47); ++j) {}

params[n] = {
name: e.prefix.substring(1),
Expand Down Expand Up @@ -217,7 +217,7 @@ class Router {
function lcp(a, b) {
let i = 0;
let max = Math.min(a.length, b.length);
for (; i < max && (a.charCodeAt(i) === b.charCodeAt(i)); i++) {}
for (; i < max && (a.charCodeAt(i) === b.charCodeAt(i)); ++i) {}
return i;
}

Expand Down

0 comments on commit 51b5e5e

Please sign in to comment.