From 8c816ebfbcb4b558ce5624da435ee26364e98da4 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Thu, 22 Dec 2022 17:23:13 -0500 Subject: [PATCH] whisper: Use emplace_back in place of push_back This avoids potential construction of temporaries. --- whisper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whisper.cpp b/whisper.cpp index 367aa2e..91b8bcc 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -1863,7 +1863,7 @@ static whisper_token_data whisper_sample_best( probs_id.reserve(n_logits); for (int i = 0; i < n_logits; i++) { - probs_id.push_back(std::make_pair(probs[i], i)); + probs_id.emplace_back(probs[i], i); } { @@ -2433,7 +2433,7 @@ int whisper_lang_auto_detect( std::vector> probs_id; for (const auto & kv : g_lang) { const auto token_lang = whisper_token_lang(ctx, kv.second.first); - probs_id.push_back({ ctx->probs[token_lang], kv.second.first }); + probs_id.emplace_back( ctx->probs[token_lang], kv.second.first ); } // sort descending