RegexpBuilder: fixed a missed optimization due to duplicate input