From 09a76ca1ee331a566cb1097f4b3dd2b8c4b13639 Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka Date: Sun, 4 Nov 2018 15:10:51 +0900 Subject: [PATCH 1/3] dfa: count the number of states reset Count the number of states reset. It may be used to determine whether dfa is enough fast or not. * lib/dfa.c (struct dfa): New member 'reset_count'. (dfaexec_main): If dfa states are reset, count up it. (dfaresetcount): New function. * lib/dfa.h (dfaresetcount): Add prototype. --- lib/dfa.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/lib/dfa.c b/lib/dfa.c index ad2716b..4b5c9bb 100644 --- a/lib/dfa.c +++ b/lib/dfa.c @@ -559,6 +559,8 @@ struct dfa ANYCHAR. */ state_num mb_trcount; /* Number of transition tables for states with ANYCHAR that have actually been built. */ + size_t reset_count; /* Number of times which the states was reset + in dfaexec. */ /* Information derived from the locale. This is at the end so that a quick memset need not clear it specially. */ @@ -3379,6 +3381,8 @@ dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl, d->states[s].mb_trindex = -1; d->mb_trcount = 0; } + + d->reset_count++; } if (!d->tralloc) @@ -3574,6 +3578,12 @@ dfaisfast (struct dfa const *d) return d->fast; } +size_t +dfaresetcount (struct dfa const *d) +{ + return d->reset_count; +} + static void free_mbdata (struct dfa *d) { -- 1.7.1