Skip to content

Commit

Permalink
Move OnChange callback in Option ctors
Browse files Browse the repository at this point in the history
Parameter 'f' is passed by value and only copied once. Moving it to
avoid unnecessary copies.

closes official-stockfish#5014

No functional change
  • Loading branch information
wcdbmv authored and Disservin committed Jan 26, 2024
1 parent 37bd1e7 commit c17ec95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/ucioption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,37 @@ Option::Option(const char* v, OnChange f) :
type("string"),
min(0),
max(0),
on_change(f) {
on_change(std::move(f)) {
defaultValue = currentValue = v;
}

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");
}

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);
}

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;
}
Expand Down

0 comments on commit c17ec95

Please sign in to comment.