using emplace_back instead of push_back

* using emplace_back instead of push_back is giving better results in regards of the memory management and crashes
* we tried with all our best ideas, we don't know why it's better but it outperformed every other allocations method tested
This commit is contained in:
gullradriel 2023-06-22 22:26:15 +02:00 committed by GitHub
parent 6a28987a36
commit 0c75713820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,7 +205,8 @@ bool load_freqman_file(std::string& file_stem, freqman_db& db, bool load_freqs,
description.shrink_to_fit(); description.shrink_to_fit();
} }
if ((type == SINGLE && load_freqs) || (type == RANGE && load_ranges) || (type == HAMRADIO && load_hamradios)) { if ((type == SINGLE && load_freqs) || (type == RANGE && load_ranges) || (type == HAMRADIO && load_hamradios)) {
db.push_back({frequency_a, frequency_b, description, type, modulation, bandwidth, step, tone}); freqman_entry entry = {frequency_a, frequency_b, std::move(description), type, modulation, bandwidth, step, tone};
db.emplace_back(entry);
n++; n++;
if (n > max_num_freqs) return true; if (n > max_num_freqs) return true;
} }