From 494d7673d17e8bb1d8e1e9bfa1c9874f42614911 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Fri, 3 Jan 2020 10:00:22 -0500 Subject: [PATCH] Reduce copies with const refs and moves in various ll libs --- indra/llcommon/lltrace.h | 2 +- indra/llcommon/lluuid.h | 3 ++- indra/llinventory/llparcel.h | 2 +- indra/llplugin/llpluginclassmedia.h | 4 ++-- indra/llrender/llfontfreetype.h | 9 ++++----- indra/llui/lliconctrl.h | 2 +- indra/llui/lltextbase.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index f218af67d3..828ea634eb 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -294,7 +294,7 @@ struct MeasureMem<T*, IS_MEM_TRACKABLE, IS_BYTES> template<typename T, typename IS_MEM_TRACKABLE, typename IS_BYTES> struct MeasureMem<LLPointer<T>, IS_MEM_TRACKABLE, IS_BYTES> { - static size_t measureFootprint(const LLPointer<T> value) + static size_t measureFootprint(const LLPointer<T>& value) { if (value.isNull()) { diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 30a029106f..bfdcc7d9cd 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -57,7 +57,8 @@ public: explicit LLUUID(const char *in_string); // Convert from string. explicit LLUUID(const std::string& in_string); // Convert from string. LLUUID(const LLUUID &rhs) = default; - LLUUID &operator=(const LLUUID &rhs) = default; + LLUUID& operator=(const LLUUID& rhs) = default; + LLUUID& operator=(LLUUID&& rhs) = default; ~LLUUID() = default; // diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 39cbf3faaf..5eeb05fb27 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -582,7 +582,7 @@ public: void setRegionAllowAccessOverride(BOOL override) { mRegionAllowAccessoverride = override; } // Accessors for parcel sellWithObjects - void setPreviousOwnerID(LLUUID prev_owner) { mPreviousOwnerID = prev_owner; } + void setPreviousOwnerID(const LLUUID& prev_owner) { mPreviousOwnerID = prev_owner; } void setPreviouslyGroupOwned(BOOL b) { mPreviouslyGroupOwned = b; } void setSellWithObjects(BOOL b) { setParcelFlag(PF_SELL_PARCEL_OBJECTS, b); } diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 15f6de029f..dbd7d70702 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -86,7 +86,7 @@ public: void setAutoScale(bool auto_scale); void setZoomFactor(F64 zoom_factor) { mZoomFactor = zoom_factor; } - void setBackgroundColor(LLColor4 color) { mBackgroundColor = color; }; + void setBackgroundColor(const LLColor4& color) { mBackgroundColor = color; }; void setOwner(LLPluginClassMediaOwner *owner) { mOwner = owner; }; @@ -148,7 +148,7 @@ public: // "Exited" means any regular or error state after "Running" (plugin may have crashed or exited normally) bool isPluginExited(void) { return mPlugin?mPlugin->isDone():false; }; - std::string getPluginVersion() { return mPlugin?mPlugin->getPluginVersion():std::string(""); }; + std::string getPluginVersion() { return mPlugin?mPlugin->getPluginVersion():std::string(); }; bool getDisableTimeout() { return mPlugin?mPlugin->getDisableTimeout():false; }; void setDisableTimeout(bool disable) { if(mPlugin) mPlugin->setDisableTimeout(disable); }; diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index 4521be4e65..884cf86050 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -59,11 +59,10 @@ private: struct LoadedFont { LoadedFont(std::string aName, std::unique_ptr<U8[]> aAddress, long aSize) - : mAddress(std::move(aAddress)) - { - mName = aName; - mSize = aSize; - } + : mName(std::move(aName)) + , mAddress(std::move(aAddress)) + , mSize(aSize) + { } std::string mName; std::unique_ptr<U8[]> mAddress; diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index 3da6356482..80400c667a 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -75,7 +75,7 @@ public: std::string getImageName() const; void setColor(const LLColor4& color) override { mColor = color; } - void setImage(LLPointer<LLUIImage> image) { mImagep = image; } + void setImage(LLPointer<LLUIImage> image) { mImagep = std::move(image); } const LLPointer<LLUIImage> getImage() const { return mImagep; } protected: diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index db7fd76d5b..5433ff4951 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -130,7 +130,7 @@ public: /*virtual*/ bool canEdit() const override { return true; } /*virtual*/ const LLColor4& getColor() const override { return mStyle->getColor(); } /*virtual*/ LLStyleConstSP getStyle() const override { return mStyle; } - /*virtual*/ void setStyle(LLStyleConstSP style) override { mStyle = style; } + /*virtual*/ void setStyle(LLStyleConstSP style) override { mStyle = std::move(style); } /*virtual*/ void setToken( LLKeywordToken* token ) override { mToken = token; } /*virtual*/ LLKeywordToken* getToken() const override { return mToken; } /*virtual*/ BOOL getToolTip( std::string& msg ) const; -- GitLab