From 6c646200c6088f587f4d6ebfa16eda80f254e434 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 20 Jan 2023 11:39:31 -0500 Subject: [PATCH] dfa: fix approximate cache size Unbelievably, this was using the size of the compiled prog *and* the heap memory used by the cache to compute the total memory used by the cache. The effect of this is that the reported size might be much bigger than what is actually used by the cache. This in turn would result in the lazy DFA thrashing the cache and going quite slow. --- src/dfa.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dfa.rs b/src/dfa.rs index dc9952120..78ed71021 100644 --- a/src/dfa.rs +++ b/src/dfa.rs @@ -1576,7 +1576,7 @@ impl<'a> Fsm<'a> { /// inputs, a new state could be created for every byte of input. (This is /// bad for memory use, so we bound it with a cache.) fn approximate_size(&self) -> usize { - self.cache.size + self.prog.approximate_size() + self.cache.size } }