Skip to content

Commit 0064eb2

Browse files
committed
const to node * n
1 parent 0d2ae75 commit 0064eb2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

include/r3.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ int r3_tree_render_file(node * tree, char * format, char * filename);
124124

125125
int r3_tree_render_dot(node * tree);
126126

127-
edge * r3_node_find_edge_str(node * n, char * str, int str_len);
127+
edge * r3_node_find_edge_str(const node * n, char * str, int str_len);
128128

129129

130130
void r3_tree_compile(node *n);
131131

132132
void r3_tree_compile_patterns(node * n);
133133

134-
node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry);
134+
node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * entry);
135135

136136
#define r3_tree_match(n,p,e) r3_tree_matchl(n,p, strlen(p), e)
137137

@@ -165,7 +165,7 @@ void r3_node_append_route(node * n, route * route);
165165

166166
void r3_route_free(route * route);
167167

168-
route * r3_tree_match_route(node *n, match_entry * entry);
168+
route * r3_tree_match_route(const node *n, match_entry * entry);
169169

170170
#define METHOD_GET 2
171171
#define METHOD_POST 2<<1

src/node.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void match_entry_free(match_entry * entry) {
252252
* @param int path_len the length of the URL path.
253253
* @param match_entry* entry match_entry is used for saving the captured dynamic strings from pcre result.
254254
*/
255-
node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) {
255+
node * r3_tree_matchl(const node * n, char * path, int path_len, match_entry * entry) {
256256
info("try matching: %s\n", path);
257257

258258
edge *e;
@@ -328,7 +328,7 @@ node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry)
328328
return NULL;
329329
}
330330

331-
route * r3_tree_match_route(node *tree, match_entry * entry) {
331+
route * r3_tree_match_route(const node *tree, match_entry * entry) {
332332
node *n;
333333
n = r3_tree_match_entry(tree, entry);
334334
if (n->routes && n->route_len > 0) {
@@ -342,7 +342,7 @@ route * r3_tree_match_route(node *tree, match_entry * entry) {
342342
return NULL;
343343
}
344344

345-
inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) {
345+
inline edge * r3_node_find_edge_str(const node * n, char * str, int str_len) {
346346
int i = 0;
347347
int matched_idx = 0;
348348
char firstbyte = *str;

tests/bench_str.csv

+4
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,7 @@
428428
1400606406,13923000.83
429429
1400606409,13742645.62
430430
1400606411,13878225.03
431+
1400606451,13922301.44
432+
1400606491,14030387.83
433+
1400606523,13157029.51
434+
1400606567,13999364.95

0 commit comments

Comments
 (0)