diff --git a/include/r3.h b/include/r3.h index 5bc76e1..271ca93 100644 --- a/include/r3.h +++ b/include/r3.h @@ -124,6 +124,8 @@ void r3_tree_compile_patterns(node * n); node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry); +node * r3_tree_match_with_entry(node * n, match_entry * entry); + bool r3_node_has_slug_edges(node *n); edge * r3_edge_create(char * pattern, int pattern_len, node * child); @@ -148,8 +150,6 @@ condition * condition_createl(char * path, int path_len); int condition_cmp(condition *r1, condition *r2); -edge * r3_edge_route_create(condition * condition, node * child); - void r3_node_append_condition(node * n, condition * condition, void * data); void condition_free(condition * condition); diff --git a/src/node.c b/src/node.c index 58789b2..fe49e76 100644 --- a/src/node.c +++ b/src/node.c @@ -211,6 +211,11 @@ void match_entry_free(match_entry * entry) { } +node * r3_tree_match_with_entry(node * n, match_entry * entry) { + return r3_tree_match(n, entry->path, entry->path_len, entry); +} + + /** * This function matches the URL path and return the left node * @@ -573,22 +578,4 @@ void r3_node_append_condition(node * n, condition * condition, void * data) { n->conditions[ n->condition_len++ ] = condition; } -/** - * Create a condition-only edge. (without pattern) - */ -edge * r3_edge_route_create(condition * condition, node * child) { - edge * e = (edge*) malloc( sizeof(edge) ); - /* - e->pattern = NULL; - e->pattern_len = 0; - e->child = child; - // e->condition = NULL; - */ - return e; -} -/* -char * r3_node_trace(node * n) { - -} -*/ diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 91637b4..8005612 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -121,3 +121,7 @@ 1400387232,11035725.37 1400387264,11006703.61 1400387291,11123431.08 +1400387303,10762934.26 +1400387318,10842286.92 +1400387384,10651069.93 +1400387532,11055554.04 diff --git a/tests/check_tree.c b/tests/check_tree.c index 5123940..3493796 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -261,6 +261,9 @@ START_TEST(test_insert_route) r3_tree_insert_route(n, r1, &var1); r3_tree_insert_route(n, r2, &var2); + node *m; + m = r3_tree_match(n , "/qux/bar/corge", strlen("/qux/bar/corge"), NULL); + match_entry_free(entry); condition_free(r1); condition_free(r2);