fix: optimization: PVS-Studio warning V837

Replaced 'emplace' with 'try_emplace' to avoid unnecessary copies or moves when insertion fails.

The 'emplace' function does not guarantee that arguments will not be copied or moved if insertion is not successful. Using 'try_emplace' ensures that arguments are only copied or moved if the insertion actually takes place, thus improving performance.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov 2024-08-02 01:39:17 +03:00 committed by Pugemon
parent 7fbd32b8df
commit 307ffc3c8f
No known key found for this signature in database
GPG Key ID: 472FA343B3CC3287

View File

@ -115,7 +115,7 @@ void Events::bind(const std::string& name, inputtype type, mousecode code) {
}
void Events::bind(const std::string& name, inputtype type, int code) {
bindings.emplace(name, Binding(type, code));
bindings.try_emplace(name, Binding(type, code));
}
void Events::rebind(const std::string& name, inputtype type, int code) {