]> xenbits.xensource.com Git - libvirt.git/commit
x86ModelParseFeatures: Don't construct list using 'virStringListAdd'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 5 Feb 2021 14:20:44 +0000 (15:20 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Feb 2021 16:05:32 +0000 (17:05 +0100)
commitfb51b85ea2354ef15178ead3cfa32f3b08369ac5
tree05fde8e8418385813be02b57cf772b8856db59b6
parentdad3827d6ac58a068c508e237c4a26249bcc59d8
x86ModelParseFeatures: Don't construct list using 'virStringListAdd'

Pre-allocate the list to the upper bound and fill it gradually. Since
the data is kept long-term and the list won't be populated much shrink
it to the actual size after parsing.

While using 'virStringListAdd' here wouldn't be as expensive as this
function is used just once, the removal will allow to remove
'virStringListAdd' altogether to discourage the antipattern it promotes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/cpu/cpu_x86.c