JAL-3878 Improve performance of gap sequence construction.