]> xenbits.xensource.com Git - libvirt.git/commit
virResctrlMonitorGetStats: Don't use 'virStringListAdd'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 5 Feb 2021 14:30:02 +0000 (15:30 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Feb 2021 16:05:32 +0000 (17:05 +0100)
commitb297714793f702cd7e42b46dc05e2cf66921ef5f
treec381541ac99057a5038b8befb7d54f231b1cadca
parent34088ea47f7a09db7474ab4dd9f558e00f1acdc4
virResctrlMonitorGetStats: Don't use 'virStringListAdd'

The iner loop copies the 'resources' array multiple times using
'virStringListAdd' which has O(n^2) complexity.

Pre-calculate the length so we can allocate the array upfront and just
copy the strings in the loop.

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