Speedup an algorithm of range parsing.