We only really need to build up a set of valid characters in the input alphabet once, in the generateDecoder factory function. Then, we can get rid of toCharset (and make isValid string -> set[char] -> bool instead of string -> string -> bool).
This makes the decoder function more efficient, since we aren't repeatedly constructing the character set of valid characters on each call.
We only really need to build up a set of valid characters in the input alphabet once, in the
generateDecoderfactory function. Then, we can get rid oftoCharset(and makeisValidstring -> set[char] -> bool instead of string -> string -> bool).This makes the decoder function more efficient, since we aren't repeatedly constructing the character set of valid characters on each call.