Skip to content

Commit

Permalink
perf(all): minor loop optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 2, 2016
1 parent 4af085d commit 897146a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/route-recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function parse(route, names, types) {
let results = [];

let splitRoute = normalizedRoute.split('/');
for (let i = 0; i < splitRoute.length; i++) {
for (let i = 0, ii = splitRoute.length; i < ii; ++i) {
let segment = splitRoute[i];
let match = segment.match(/^:([^\/]+)$/);
if (match) {
Expand Down
5 changes: 3 additions & 2 deletions src/segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export class StaticSegment {
}

eachChar(callback: (spec: CharSpec) => void): void {
for (let i = 0; i < this.string.length; i++) {
let ch = this.string[i];
let s = this.string;
for (let i = 0, ii = s.length; i < ii; ++i) {
let ch = s[i];
callback({ validChars: ch });
}
}
Expand Down

0 comments on commit 897146a

Please sign in to comment.