This is a good optimization when you can use it, but it is somewhat uncommon to decode a large number of consecutive symbols using the same Huffman code. Actual compression formats switch between multiple codes, as one switches between decoding prediction modes, literals, run lengths, offsets, and etc., and more importantly, you often do not know the code that will be used for the next symbol before you have decoded the previous symbols. That all makes it rather difficult to apply in practice.