You will find that for rimfires, the maximum velocity is acheived around 18" or so. There is just not enough powder in the case to keep accelerating the bullet.
Most pistol cartridges reach maximum velocities about the same barrel distance too.
And for rifle barrels, between my 308 caliber barrels, between 24" and 26", velocity is more dependent on the individual barrel than in the length. Some barrels just push the bullet faster, and the loads have to be cut.