performance improvement on plain string edge matching
This commit is contained in:
parent
00c3b32ad5
commit
c1d90dd138
3 changed files with 13 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <pcre.h>
|
||||
#include <gvc.h>
|
||||
|
||||
#include "str_array.h"
|
||||
|
||||
|
@ -133,5 +134,6 @@ match_entry * match_entry_create(char * path, int path_len);
|
|||
|
||||
void match_entry_free(match_entry * entry);
|
||||
|
||||
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt);
|
||||
|
||||
#endif /* !NODE_H */
|
||||
|
|
|
@ -17,7 +17,7 @@ char * node_id_str(int id) {
|
|||
return name;
|
||||
}
|
||||
|
||||
int r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt) {
|
||||
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt) {
|
||||
edge * e;
|
||||
Agnode_t *agn_child;
|
||||
Agedge_t *agn_edge;
|
||||
|
|
13
src/node.c
13
src/node.c
|
@ -299,12 +299,19 @@ node * r3_tree_match(node * n, char * path, int path_len, match_entry * entry) {
|
|||
|
||||
inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) {
|
||||
int i = 0;
|
||||
int matched_idx = 0;
|
||||
|
||||
for (; i < n->edge_len ; i++ ) {
|
||||
info("matching '%s' with '%s'\n", str, node_edge_pattern(n,i) );
|
||||
if ( strncmp( node_edge_pattern(n,i), str, node_edge_pattern_len(n,i) ) == 0 ) {
|
||||
return n->edges[i];
|
||||
if ( *str == *(n->edges[i]->pattern) ) {
|
||||
matched_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// info("matching '%s' with '%s'\n", str, node_edge_pattern(n,i) );
|
||||
if ( strncmp( node_edge_pattern(n,matched_idx), str, node_edge_pattern_len(n,matched_idx) ) == 0 ) {
|
||||
return n->edges[matched_idx];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue