Optimized the prefix ("pos slot") code in the distance encoder.
It now uses lookup tables for short distances and an optimized "count leading zeros" algorithm.