From c17ec9524d57c2fdaba1fd7f16ce30744780b6aa Mon Sep 17 00:00:00 2001 From: Ahmed Kerimov Date: Fri, 26 Jan 2024 13:52:56 +0300 Subject: [PATCH] Move OnChange callback in Option ctors Parameter 'f' is passed by value and only copied once. Moving it to avoid unnecessary copies. closes https://github.com/official-stockfish/Stockfish/pull/5014 No functional change --- AUTHORS | 1 + src/ucioption.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index a179d273d04..cc8edafa4aa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ Hisayori Noda (nodchip) # All other authors of Stockfish code (in alphabetical order) Aditya (absimaldata) Adrian Petrescu (apetresc) +Ahmed Kerimov (wcdbmv) Ajith Chandy Jose (ajithcj) Alain Savard (Rocky640) Alayan Feh (Alayan-stk-2) diff --git a/src/ucioption.cpp b/src/ucioption.cpp index c7de7e3f7f2..e1ffe546525 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -68,7 +68,7 @@ Option::Option(const char* v, OnChange f) : type("string"), min(0), max(0), - on_change(f) { + on_change(std::move(f)) { defaultValue = currentValue = v; } @@ -76,7 +76,7 @@ Option::Option(bool v, OnChange f) : type("check"), min(0), max(0), - on_change(f) { + on_change(std::move(f)) { defaultValue = currentValue = (v ? "true" : "false"); } @@ -84,13 +84,13 @@ Option::Option(OnChange f) : type("button"), min(0), max(0), - on_change(f) {} + on_change(std::move(f)) {} Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), - on_change(f) { + on_change(std::move(f)) { defaultValue = currentValue = std::to_string(v); } @@ -98,7 +98,7 @@ Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), - on_change(f) { + on_change(std::move(f)) { defaultValue = v; currentValue = cur; }