Ammends 5320c9d8
This fixes a performance regression caught by the GDAL regression test suite.
CC @Su_Laus