diff --git a/include/r3.h b/include/r3.h index 14ec6ba..e4583f3 100644 --- a/include/r3.h +++ b/include/r3.h @@ -124,14 +124,14 @@ int r3_tree_render_file(node * tree, char * format, char * filename); int r3_tree_render_dot(node * tree); -edge * r3_node_find_edge_str(node * n, char * str, int str_len); +edge * r3_node_find_edge_str(const node * n, char * str, int str_len); void r3_tree_compile(node *n); void r3_tree_compile_patterns(node * n); -node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry); +node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * entry); #define r3_tree_match(n,p,e) r3_tree_matchl(n,p, strlen(p), e) @@ -165,7 +165,7 @@ void r3_node_append_route(node * n, route * route); void r3_route_free(route * route); -route * r3_tree_match_route(node *n, match_entry * entry); +route * r3_tree_match_route(const node *n, match_entry * entry); #define METHOD_GET 2 #define METHOD_POST 2<<1 diff --git a/src/node.c b/src/node.c index 7085e29..9741e40 100644 --- a/src/node.c +++ b/src/node.c @@ -252,7 +252,7 @@ void match_entry_free(match_entry * entry) { * @param int path_len the length of the URL path. * @param match_entry* entry match_entry is used for saving the captured dynamic strings from pcre result. */ -node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) { +node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * entry) { info("try matching: %s\n", path); edge *e; @@ -328,7 +328,7 @@ node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) return NULL; } -route * r3_tree_match_route(node *tree, match_entry * entry) { +route * r3_tree_match_route(const node *tree, match_entry * entry) { node *n; n = r3_tree_match_entry(tree, entry); if (n->routes && n->route_len > 0) { @@ -342,7 +342,7 @@ route * r3_tree_match_route(node *tree, match_entry * entry) { return NULL; } -inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) { +inline edge * r3_node_find_edge_str(const node * n, char * str, int str_len) { int i = 0; int matched_idx = 0; char firstbyte = *str; diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 40dc980..1b3d4f7 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -428,3 +428,7 @@ 1400606406,13923000.83 1400606409,13742645.62 1400606411,13878225.03 +1400606451,13922301.44 +1400606491,14030387.83 +1400606523,13157029.51 +1400606567,13999364.95