Fix n² complexity in cfkey

The optimizer has a helper that checks statements for equality, cfkey.  It is currently n², and could be made linear by memoization.
I don't recall the semantics of what happens when you modify something that you are iterating over, but I think it's bad.  Anyway instead of looping over the elements, just set cfkey_cache = { } and be done with it.