Do not copy objects twice where possible

macos_ci_fix
Andrei Kortunov 1 year ago
parent 5160fbc2a0
commit f5b18d2d5d

@ -532,7 +532,7 @@ namespace LuaUtil
t.mScriptId = scriptId; t.mScriptId = scriptId;
t.mSerializable = true; t.mSerializable = true;
t.mTime = time; t.mTime = time;
t.mArg = callbackArg; t.mArg = std::move(callbackArg);
t.mSerializedArg = serialize(t.mArg, mSerializer); t.mSerializedArg = serialize(t.mArg, mSerializer);
insertTimer(type == TimerType::GAME_TIME ? mGameTimersQueue : mSimulationTimersQueue, std::move(t)); insertTimer(type == TimerType::GAME_TIME ? mGameTimersQueue : mSimulationTimersQueue, std::move(t));
} }

@ -25,7 +25,7 @@ namespace LuaUi
} }
template <typename T, typename LuaT> template <typename T, typename LuaT>
sol::optional<T> parseValue(sol::object table, std::string_view field, std::string_view errorPrefix) sol::optional<T> parseValue(const sol::object& table, std::string_view field, std::string_view errorPrefix)
{ {
sol::object opt = LuaUtil::getFieldOrNil(table, field); sol::object opt = LuaUtil::getFieldOrNil(table, field);
if (opt != sol::nil && !opt.is<LuaT>()) if (opt != sol::nil && !opt.is<LuaT>())
@ -51,7 +51,7 @@ namespace LuaUi
} }
template <typename T> template <typename T>
sol::optional<T> parseValue(sol::object table, std::string_view field, std::string_view errorPrefix) sol::optional<T> parseValue(const sol::object& table, std::string_view field, std::string_view errorPrefix)
{ {
if constexpr (isMyGuiVector<T>()) if constexpr (isMyGuiVector<T>())
return parseValue<T, osg::Vec2f>(table, field, errorPrefix); return parseValue<T, osg::Vec2f>(table, field, errorPrefix);

@ -21,7 +21,7 @@ namespace LuaUi
Log(Debug::Warning) << "A script settings page has an empty name"; Log(Debug::Warning) << "A script settings page has an empty name";
if (!element.get()) if (!element.get())
Log(Debug::Warning) << "A script settings page has no UI element assigned"; Log(Debug::Warning) << "A script settings page has no UI element assigned";
return { name, searchHints, element }; return { std::move(name), std::move(searchHints), element };
} }
} }

@ -266,7 +266,7 @@ namespace LuaUi
mOnCoordChange.value()(this, newCoord); mOnCoordChange.value()(this, newCoord);
} }
void WidgetExtension::setProperties(sol::object props) void WidgetExtension::setProperties(const sol::object& props)
{ {
mProperties = props; mProperties = props;
updateProperties(); updateProperties();

@ -44,10 +44,10 @@ namespace LuaUi
void setCallback(const std::string&, const LuaUtil::Callback&); void setCallback(const std::string&, const LuaUtil::Callback&);
void clearCallbacks(); void clearCallbacks();
void setProperties(sol::object); void setProperties(const sol::object& props);
void setTemplateProperties(sol::object props) { mTemplateProperties = props; } void setTemplateProperties(const sol::object& props) { mTemplateProperties = props; }
void setExternal(sol::object external) { mExternal = external; } void setExternal(const sol::object& external) { mExternal = external; }
MyGUI::IntCoord forcedCoord(); MyGUI::IntCoord forcedCoord();
void forceCoord(const MyGUI::IntCoord& offset); void forceCoord(const MyGUI::IntCoord& offset);

Loading…
Cancel
Save