diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-07-26 20:59:45 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-07-26 20:59:45 -0700 |
| commit | f23b9bc6375797d03dee54a31fcaa634f8376975 (patch) | |
| tree | 624128655eeb20d68098e8c772d9d3ac77f1ee1e /matchviz.c | |
| parent | d7030709801cde01739850a85f156d181554f520 (diff) | |
Introduced cache to greatly speed up many use cases
Diffstat (limited to 'matchviz.c')
| -rw-r--r-- | matchviz.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -26,8 +26,9 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char * static int height_of_match(match_t *m) { int height = 0; - for (match_t *c = m->child; c; c = c->nextsibling) { - int childheight = height_of_match(c); + for (int i = 0; m->children && m->children[i]; i++) { + match_t *child = m->children[i]; + int childheight = height_of_match(child); if (childheight > height) height = childheight; } return 1 + height; @@ -83,9 +84,9 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char * // Print nonzero-width first: for (match_node_t *m = firstmatch; m; m = m->next) { if (RIGHT_TYPE(m)) { - for (match_t *c = m->m->child; c; c = c->nextsibling) { + for (int i = 0; m->m->children && m->m->children[i]; i++) { *nextchild = new(match_node_t); - (*nextchild)->m = c; + (*nextchild)->m = m->m->children[i]; nextchild = &((*nextchild)->next); } if (m->m->end == m->m->start) continue; |
