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 /json.c | |
| parent | d7030709801cde01739850a85f156d181554f520 (diff) | |
Introduced cache to greatly speed up many use cases
Diffstat (limited to 'json.c')
| -rw-r--r-- | json.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -18,9 +18,8 @@ static int _json_match(const char *text, match_t *m, int comma, bool verbose) { if (!verbose) { if (m->pat->type != BP_REF && m->pat->type != BP_ERROR) { - for (match_t *child = m->child; child; child = child->nextsibling) { - comma |= _json_match(text, child, comma, verbose); - } + for (int i = 0; m->children && m->children[i]; i++) + comma |= _json_match(text, m->children[i], comma, verbose); return comma; } } @@ -39,9 +38,8 @@ static int _json_match(const char *text, match_t *m, int comma, bool verbose) } printf("\",\"start\":%ld,\"end\":%ld,\"children\":[", m->start - text, m->end - text); - for (match_t *child = m->child; child; child = child->nextsibling) { - comma |= _json_match(text, child, comma, verbose); - } + for (int i = 0; m->children && m->children[i]; i++) + comma |= _json_match(text, m->children[i], comma, verbose); printf("]}"); return 1; } |
