Don't use local CP_RESULT_STRUCT variable to initialize elements of std::vector

std::vector passes that local variable by reference, so no individual
instances are used for the new vector elements.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-01-13 07:28:21 +01:00
parent b0e46085f4
commit 5e661b9339

View File

@ -393,8 +393,7 @@ class ClassPruner {
/// Copies the pruned, sorted classes into the output results and returns
/// the number of classes.
int SetupResults(std::vector<CP_RESULT_STRUCT>* results) const {
CP_RESULT_STRUCT empty;
results->resize(num_classes_, empty);
results->resize(num_classes_);
for (int c = 0; c < num_classes_; ++c) {
(*results)[c].Class = sort_index_[num_classes_ - c];
(*results)[c].Rating = 1.0f - sort_key_[num_classes_ - c] /