commit f9ce7ebaa6ef436f492408aa23d1ae1b6778e4c4 from: Sven M. Hallberg date: Fri Aug 07 17:10:42 2020 UTC compare symbol by pointer rather than string commit - da6b9ad4417ba3206815244901e97e80fb5a46ff commit + f9ce7ebaa6ef436f492408aa23d1ae1b6778e4c4 blob - 064dae8dd8dd7c8ae6365df380c9029dc6ae2ed5 blob + a81cec5087f86f647bb1e17a9e7f827c4868330e --- minip_n.h +++ minip_n.h @@ -206,7 +206,6 @@ many1_(struct stream inp, struct cache *cac, void *env return many_(inp, cac, env, ps, n); } -#include /* strcmp */ #include /* calloc */ #include /* UINT_MAX */ #include /* SIZE_MAX */ @@ -234,8 +233,8 @@ memo_(struct stream inp, struct cache *cache, void *en /* hash (pos,sym) */ for (i=0; i < sizeof inp.p; i++) h0 = h0 * 33 + ((unsigned char *)&inp.p)[i]; - for (i=0; sym[i] != '\0'; i++) - h0 = h0 * 33 + (unsigned char)sym[i]; + for (i=0; i < sizeof sym; i++) + h0 = h0 * 33 + ((unsigned char *)&sym)[i]; /* look up (pos,sym) in cache and return if found */ /* NB: count steps, since the table could be filled with dummies */ @@ -245,7 +244,7 @@ memo_(struct stream inp, struct cache *cache, void *en break; if (mem->symbol == NULL) /* dummy entry */ continue; - if (mem->position == inp.p && strcmp(mem->symbol, sym) == 0) + if (mem->position == inp.p && mem->symbol == sym) return mem->result; /* match */ }