diff --git a/README.md b/README.md index 92c74d2..fec0c7a 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ n = r3_tree_create(10); int route_data = 3; // insert the route path into the router tree -r3_tree_insert_pathn(n , "/zoo" , strlen("/zoo") , &route_data ); -r3_tree_insert_pathn(n , "/foo/bar" , strlen("/foo/bar") , &route_data ); -r3_tree_insert_pathn(n , "/bar" , strlen("/bar") , &route_data ); -r3_tree_insert_pathn(n , "/post/{id}" , strlen("/post/{id}") , &route_data ); +r3_tree_insert_pathl(n , "/zoo" , strlen("/zoo") , &route_data ); +r3_tree_insert_pathl(n , "/foo/bar" , strlen("/foo/bar") , &route_data ); +r3_tree_insert_pathl(n , "/bar" , strlen("/bar") , &route_data ); +r3_tree_insert_pathl(n , "/post/{id}" , strlen("/post/{id}") , &route_data ); // let's compile the tree! r3_tree_compile(n); diff --git a/include/r3.h b/include/r3.h index 9310eb2..0c22293 100644 --- a/include/r3.h +++ b/include/r3.h @@ -102,7 +102,7 @@ void r3_tree_append_edge(node *n, edge *child); node * r3_tree_insert_path(node *tree, char *path, route * route, void * data); -node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route, void * data); +node * r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route, void * data); void r3_tree_dump(node * n, int level); diff --git a/src/node.c b/src/node.c index 2535646..0d31957 100644 --- a/src/node.c +++ b/src/node.c @@ -366,10 +366,10 @@ node * r3_node_create() { node * r3_tree_insert_path(node *tree, char *path, route * route, void * data) { - return r3_tree_insert_pathn(tree, path, strlen(path) , route , data); + return r3_tree_insert_pathl(tree, path, strlen(path) , route , data); } -node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route, void * data) +node * r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route, void * data) { node * n = tree; edge * e = NULL; @@ -413,7 +413,7 @@ node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route, // there are something more we can insert if ( subroute_len > 0 ) { - return r3_tree_insert_pathn(e->child, subroute, subroute_len, route, data); + return r3_tree_insert_pathl(e->child, subroute, subroute_len, route, data); } else { // no more, e->child->endpoint++; // make it as an endpoint, TODO: put the path value diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 8f969c8..f8b33de 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -92,3 +92,4 @@ 1400382578,13521992.76 1400382591,12607054.51 1400382780,12319337.31 +1400382819,12453653.04 diff --git a/tests/check_tree.c b/tests/check_tree.c index f1f072d..3f29a21 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -55,9 +55,9 @@ START_TEST (test_compile) node *m; edge *e ; - r3_tree_insert_pathn(n, "/zoo", strlen("/zoo"), NULL, NULL); - r3_tree_insert_pathn(n, "/foo", strlen("/foo"), NULL, NULL); - r3_tree_insert_pathn(n, "/bar", strlen("/bar"), NULL, NULL); + r3_tree_insert_pathl(n, "/zoo", strlen("/zoo"), NULL, NULL); + r3_tree_insert_pathl(n, "/foo", strlen("/foo"), NULL, NULL); + r3_tree_insert_pathl(n, "/bar", strlen("/bar"), NULL, NULL); r3_tree_compile(n); fail_if( n->combined_pattern ); fail_if( NULL == r3_node_find_edge_str(n, "/", strlen("/") ) ); @@ -66,8 +66,8 @@ START_TEST (test_compile) r3_tree_dump(n, 0); #endif - r3_tree_insert_pathn(n, "/foo/{id}", strlen("/foo/{id}"), NULL, NULL); - r3_tree_insert_pathn(n, "/{id}", strlen("/{id}"), NULL, NULL); + r3_tree_insert_pathl(n, "/foo/{id}", strlen("/foo/{id}"), NULL, NULL); + r3_tree_insert_pathl(n, "/{id}", strlen("/{id}"), NULL, NULL); r3_tree_compile(n); r3_tree_compile(n); // test double compile #ifdef DEBUG @@ -160,7 +160,7 @@ START_TEST (test_compile_slug) END_TEST -START_TEST (test_r3_tree_insert_pathn) +START_TEST (test_r3_tree_insert_pathl) { node * n = r3_tree_create(10); @@ -177,15 +177,15 @@ START_TEST (test_r3_tree_insert_pathn) // r3_tree_dump(n, 0); info("Inserting /post/{id}\n"); - r3_tree_insert_pathn(n, "/post/{id}", strlen("/post/{id}"), NULL, NULL); + r3_tree_insert_pathl(n, "/post/{id}", strlen("/post/{id}"), NULL, NULL); // r3_tree_dump(n, 0); info("Inserting /post/{handle}\n"); - r3_tree_insert_pathn(n, "/post/{handle}", strlen("/post/{handle}"), NULL, NULL); + r3_tree_insert_pathl(n, "/post/{handle}", strlen("/post/{handle}"), NULL, NULL); // r3_tree_dump(n, 0); info("Inserting /post/{handle}-{id}\n"); - r3_tree_insert_pathn(n, "/post/{handle}-{id}", strlen("/post/{handle}-{id}"), NULL, NULL); + r3_tree_insert_pathl(n, "/post/{handle}-{id}", strlen("/post/{handle}-{id}"), NULL, NULL); r3_tree_compile(n); #ifdef DEBUG @@ -655,7 +655,7 @@ Suite* r3_suite (void) { tcase_add_test(tcase, test_ltrim_slash); tcase_add_test(tcase, test_r3_node_construct_uniq); tcase_add_test(tcase, test_r3_node_find_edge); - tcase_add_test(tcase, test_r3_tree_insert_pathn); + tcase_add_test(tcase, test_r3_tree_insert_pathl); tcase_add_test(tcase, test_compile_slug); tcase_add_test(tcase, test_compile);