From e401364869c370b8b0181369f184b5895d186f53 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 10 Nov 2015 20:31:36 +0800 Subject: [PATCH] Cache pointer of edge --- src/node.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node.c b/src/node.c index c0dae00..c209f44 100644 --- a/src/node.c +++ b/src/node.c @@ -133,12 +133,14 @@ edge * r3_node_append_edge(node *n, edge *e) * if "pat" is a slug, we should compare with the specified pattern. */ edge * r3_node_find_edge(const node * n, const char * pat, int pat_len) { + edge * e; int i; for (i = 0 ; i < n->edge_len ; i++ ) { + e = &n->edges[i]; // there is a case: "{foo}" vs "{foo:xxx}", // we should return the match result: full-match or partial-match - if (strcmp(n->edges[i].pattern, pat) == 0) { - return &n->edges[i]; + if (strcmp(e->pattern, pat) == 0) { + return e; } } return NULL;