Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support router serialization. #90

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
71f82f3
Support router serialization.
nathanhammond May 3, 2016
df6f54f
Make this work in non-ES6 browsers.
nathanhammond May 3, 2016
d8c14b7
Add serialized benchmark.
nathanhammond May 3, 2016
942ccff
Fix benchmark.
nathanhammond May 4, 2016
2953157
Add trie approach.
nathanhammond May 10, 2016
9082ccb
Implement add.
nathanhammond May 11, 2016
678b80a
Implement handlersFor, generateQueryString, and parseQueryString.
nathanhammond May 11, 2016
47aa7b0
Add in trie walk function.
nathanhammond May 14, 2016
fc191b0
Make specificity work. Add documentation. Start params work.
nathanhammond May 16, 2016
41aa352
Correct glob leaf behavior.
nathanhammond May 16, 2016
6d06924
First pass at params.
nathanhammond May 16, 2016
40b82a4
Move the trie approach to default.
nathanhammond May 16, 2016
e9ca2ae
Support query params.
nathanhammond May 16, 2016
cb82a91
Properly remove handlers.
nathanhammond May 16, 2016
8d88f51
Simple param reinsertion for globbing routes.
nathanhammond May 16, 2016
d4322a9
Run all tests.
nathanhammond May 16, 2016
5b44be5
Return null from recognize for misses. Prepend paths with '/'.
nathanhammond May 16, 2016
e30ee48
Naive fix for empty segments.
nathanhammond May 16, 2016
6406030
Throw on generate mismatch.
nathanhammond May 16, 2016
85989b6
Write generate.
nathanhammond May 16, 2016
bb63cb4
Remove the original implementations.
nathanhammond May 16, 2016
6204ff6
Stop scanning entire strings.
nathanhammond May 16, 2016
c132ddb
JIT compacting.
nathanhammond May 16, 2016
8e41401
Revert "Stop scanning entire strings."
nathanhammond May 16, 2016
e812aa4
`push` is much faster than `unshift`.
nathanhammond May 17, 2016
1dc7369
Convert matcher to pure loops.
nathanhammond May 17, 2016
87d0b2f
Fix generate.
nathanhammond May 17, 2016
294d59f
Remove Function#bind.
nathanhammond May 17, 2016
f6ae1b6
Move to charCodeAt.
nathanhammond May 23, 2016
6d99dbe
Include serialization.
nathanhammond May 23, 2016
3ef18b6
Achieved JSON.stringify(router) === JSON.stringify(new RouteRecognize…
nathanhammond May 23, 2016
8ab70f9
Serialization/hydration works.
nathanhammond May 24, 2016
9e10f5f
First pass at adding normalization to the trie approach.
nathanhammond May 24, 2016
48673d8
Fix more tests.
nathanhammond May 24, 2016
cec2193
Breaking apart the monolith.
nathanhammond May 24, 2016
8404854
Broken support of addRouteCallback.
nathanhammond May 28, 2016
15972cd
Clean up tracing.
nathanhammond May 29, 2016
4139fcb
Appears to work for static routes.
nathanhammond May 30, 2016
c3aba6e
Fix param handling.
nathanhammond May 30, 2016
3cfaa9c
Fix removal during compaction.
nathanhammond May 30, 2016
1f3e4a4
Fix merging of named routes.
nathanhammond May 30, 2016
96f2f5c
Update dist versions.
nathanhammond May 30, 2016
4a5e910
Fix leaf node tracking.
nathanhammond Jun 28, 2016
0d50753
Prevent partial static segment matching.
nathanhammond Jun 28, 2016
be044e6
Fix boolean logic for popping handlers.
nathanhammond Jun 29, 2016
bd58105
Fix dynamic setting for non-handler routes.
nathanhammond Jun 30, 2016
f1d4d55
Fix node rejection.
nathanhammond Jun 30, 2016
19d44d9
Temporary workaround for API change introduced by @bantic.
nathanhammond Jun 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bench/benches/serialize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var RouteRecognizer = require('../../dist/route-recognizer');

var router = new RouteRecognizer();

router.map(function(match) {
var i = 1000;
while (i--) {
match('/posts/' + i).to('showPost' + i);
}
});

var serialized = JSON.parse(router.toJSON());

module.exports = {
name: 'Serialized',
fn: function() {
var router = new RouteRecognizer(serialized);

// Look up time is constant
router.recognize('/posts/1');
Copy link
Collaborator

@chadhietala chadhietala May 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking at the wrong RR instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, rerunning benchmark now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No faster: it wouldn't be, thinking about it. That new RouteRecognizer(serialized); is stupidly expensive for some reason.

}
};
Loading