Skip to content

lib/generic/array: avoid quadratic work for long arrays

Vladimír Čunát requested to merge array-reserve into master

For long arrays we really want to increase their length by a fraction. Otherwise it will cost lots of CPU. Doubling seems customary, though I could imagine e.g. keeping the +50% growth on longest arrays.

I finally got sufficiently angry with this piece of code when debugging https://forum.turris.cz/t/how-to-debug-a-custom-hosts-file-for-kresd/17449 though in that case it wasn't the main source of inefficiency.

CI: two of the mysterious/bogus warnings around arrays disappeared.

Merge request reports