Speed up of token iteration loop