Commit 1206a9dd authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Reduce string copies

parent cf6d0713
......@@ -45,8 +45,8 @@ class LLCurrencyWrapper final : public LLSingleton<LLCurrencyWrapper>
public:
void setCurrency(const std::string& currency);
void setHomeCurrency(const std::string& currency);
std::string getCurrency() const { return mCurrency; }
std::string getHomeCurrency() const { return mHomeCurrency; }
const std::string& getCurrency() const { return mCurrency; }
const std::string& getHomeCurrency() const { return mHomeCurrency; }
std::string wrapCurrency(const std::string& to_substitute) const;
void wrapCurrency(std::string& to_substitute) const;
......
......@@ -216,8 +216,8 @@ public:
void setImageOverlayBottomPad( S32 pad ) { mImageOverlayBottomPad = pad; }
S32 getImageOverlayBottomPad() const { return mImageOverlayBottomPad; }
const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); }
const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); }
const std::string& getLabelUnselected() const { return mUnselectedLabel.getString(); }
const std::string& getLabelSelected() const { return mSelectedLabel.getString(); }
void setImageColor(const LLColor4& c);
/*virtual*/ void setColor(const LLColor4& c) override;
......
......@@ -492,7 +492,7 @@ public:
* Sets up new filter string and filters the list.
*/
void setFilterSubString(const std::string& filter_str);
std::string getFilterSubString() const { return mFilterSubString; }
const std::string& getFilterSubString() const { return mFilterSubString; }
/**
* Filters the list, rearranges and notifies parent about shape changes.
......
......@@ -1713,7 +1713,7 @@ void LLTabContainer::setTitle(const std::string& title)
}
}
const std::string LLTabContainer::getPanelTitle(S32 index)
const std::string& LLTabContainer::getPanelTitle(S32 index)
{
if (index >= 0 && index < (S32)mTabList.size())
{
......
......@@ -202,7 +202,7 @@ public:
void setTabImage(LLPanel* child, const LLUUID& img_id, const LLColor4& color = LLColor4::white);
void setTabImage(LLPanel* child, LLIconCtrl* icon);
void setTitle( const std::string& title );
const std::string getPanelTitle(S32 index);
const std::string& getPanelTitle(S32 index);
void setTopBorderHeight(S32 height);
S32 getTopBorderHeight() const;
......
......@@ -248,7 +248,7 @@ void LLView::setToolTipArgs( const LLStringUtil::format_map_t& args )
const std::string LLView::getToolTip() const
{
if (!mToolTipMsg || !mToolTipMsg[0])
return "";
return std::string();
if (mTooltipArgs)
{
......
......@@ -1264,7 +1264,7 @@ LLAOSet* LLAOEngine::getSetByName(const std::string& name) const
return found;
}
const std::string LLAOEngine::getCurrentSetName() const
const std::string& LLAOEngine::getCurrentSetName() const
{
if(mCurrentSet)
{
......
......@@ -129,7 +129,7 @@ public:
static void onLoginComplete();
const std::vector<LLAOSet*> getSetList() const;
const std::string getCurrentSetName() const;
const std::string& getCurrentSetName() const;
const LLAOSet* getDefaultSet() const;
bool renameSet(LLAOSet* set, const std::string& name);
......
......@@ -83,7 +83,7 @@ public:
void sortByName();
void setShowIcons(std::string param_name);
bool getIconsVisible() const { return mShowIcons; }
const std::string getIconParamName() const {return mIconParamName;}
const std::string& getIconParamName() const {return mIconParamName;}
std::string getAvatarName(const LLAvatarName& av_name);
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override;
BOOL handleMouseDown( S32 x, S32 y, MASK mask ) override;
......
......@@ -493,7 +493,7 @@ void LLFloaterBuyLandUI::updateCovenantInfo()
if(!region) return;
U8 sim_access = region->getSimAccess();
std::string rating = LLViewerRegion::accessToString(sim_access);
const std::string& rating = LLViewerRegion::accessToString(sim_access);
LLTextBox* region_name = getChild<LLTextBox>("region_name_text");
if (region_name)
......
......@@ -387,7 +387,7 @@ void LLInventoryPanel::setFilterSubString(const std::string& string)
getFilter().setFilterSubString(string);
}
const std::string LLInventoryPanel::getFilterSubString()
const std::string& LLInventoryPanel::getFilterSubString()
{
return getFilter().getFilterSubString();
}
......
......@@ -179,7 +179,7 @@ public:
U32 getFilterPermMask() const;
void setFilterWearableTypes(U64 filter);
void setFilterSubString(const std::string& string);
const std::string getFilterSubString();
const std::string& getFilterSubString();
void setSinceLogoff(BOOL sl);
void setHoursAgo(U32 hours);
void setDateSearchDirection(U32 direction);
......
......@@ -655,7 +655,7 @@ void LLPanelMainInventory::onFilterSelected()
setFilterTextFromFilter();
}
const std::string LLPanelMainInventory::getFilterSubString()
const std::string& LLPanelMainInventory::getFilterSubString()
{
return mActivePanel->getFilterSubString();
}
......
......@@ -110,7 +110,7 @@ protected:
static BOOL incrementalFind(LLFolderViewItem* first_item, const char *find_text, BOOL backward);
void onFilterSelected();
const std::string getFilterSubString();
const std::string& getFilterSubString();
void setFilterSubString(const std::string& string);
// menu callbacks
......
......@@ -390,7 +390,7 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel,
mEstateRatingIcon->setValue(icon_pg);
}
std::string rating = LLViewerRegion::accessToString(sim_access);
const std::string& rating = LLViewerRegion::accessToString(sim_access);
mParcelRatingText->setText(rating);
mRegionRatingText->setText(rating);
......
......@@ -841,7 +841,7 @@ BOOL LLViewerRegion::canManageEstate() const
|| gAgent.getID() == getOwner();
}
const std::string LLViewerRegion::getSimAccessString() const
const std::string& LLViewerRegion::getSimAccessString() const
{
return accessToString(mSimAccess);
}
......@@ -871,7 +871,7 @@ std::string LLViewerRegion::regionFlagsToString(U64 flags)
}
// static
std::string LLViewerRegion::accessToString(U8 sim_access)
const std::string& LLViewerRegion::accessToString(U8 sim_access)
{
switch (sim_access)
{
......@@ -907,42 +907,51 @@ std::string LLViewerRegion::accessToString(U8 sim_access)
}
// static
std::string LLViewerRegion::getAccessIcon(U8 sim_access)
const std::string& LLViewerRegion::getAccessIcon(U8 sim_access)
{
static const std::string parcel_m_dark("Parcel_M_Dark");
static const std::string parcel_r_light("Parcel_R_Light");
static const std::string parcel_pg_light("Parcel_PG_Light");
switch(sim_access)
{
case SIM_ACCESS_MATURE:
return "Parcel_M_Dark";
return parcel_m_dark;
case SIM_ACCESS_ADULT:
return "Parcel_R_Light";
return parcel_r_light;
case SIM_ACCESS_PG:
return "Parcel_PG_Light";
return parcel_pg_light;
case SIM_ACCESS_MIN:
default:
return "";
return LLStringUtil::null;
}
}
// static
std::string LLViewerRegion::accessToShortString(U8 sim_access)
const std::string& LLViewerRegion::accessToShortString(U8 sim_access)
{
static const std::string ACCESS_PG_SHORT_STR("PG");
static const std::string ACCESS_MATURE_SHORT_STR("M");
static const std::string ACCESS_ADULT_SHORT_STR("A");
static const std::string ACCESS_MIN_SHORT_STR("U");
switch(sim_access) /* Flawfinder: ignore */
{
case SIM_ACCESS_PG:
return "PG";
return ACCESS_PG_SHORT_STR;
case SIM_ACCESS_MATURE:
return "M";
return ACCESS_MATURE_SHORT_STR;
case SIM_ACCESS_ADULT:
return "A";
return ACCESS_ADULT_SHORT_STR;
case SIM_ACCESS_MIN:
default:
return "U";
return ACCESS_MIN_SHORT_STR;
}
}
......
......@@ -192,7 +192,7 @@ public:
void setSimAccess(U8 sim_access) { mSimAccess = sim_access; }
U8 getSimAccess() const { return mSimAccess; }
const std::string getSimAccessString() const;
const std::string& getSimAccessString() const;
// Homestead-related getters; there are no setters as nobody should be
// setting them other than the individual message handler which is a member
......@@ -206,14 +206,14 @@ public:
static std::string regionFlagsToString(U64 flags);
// Returns translated version of "Mature", "PG", "Adult", etc.
static std::string accessToString(U8 sim_access);
static const std::string& accessToString(U8 sim_access);
// Returns "M", "PG", "A" etc.
static std::string accessToShortString(U8 sim_access);
static const std::string& accessToShortString(U8 sim_access);
static U8 shortStringToAccess(const std::string &sim_access);
// Return access icon name
static std::string getAccessIcon(U8 sim_access);
static const std::string& getAccessIcon(U8 sim_access);
// helper function which just makes sure all interested parties
// can process the message.
......@@ -361,8 +361,8 @@ public:
friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion &region);
/// implements LLCapabilityProvider
virtual std::string getDescription() const override;
std::string getLegacyHttpUrl() const { return mLegacyHttpUrl; }
std::string getViewerAssetUrl() const { return mViewerAssetUrl; }
const std::string& getLegacyHttpUrl() const { return mLegacyHttpUrl; }
const std::string& getViewerAssetUrl() const { return mViewerAssetUrl; }
U32 getNumOfVisibleGroups() const;
U32 getNumOfActiveCachedObjects() const;
......
......@@ -122,11 +122,11 @@ public:
// void setWaterHeight (F32 water_height) { mWaterHeight = water_height; }
// Accessors
std::string getName() const { return mName; }
const std::string& getName() const { return mName; }
const std::string getFlagsString() const { return LLViewerRegion::regionFlagsToString(mRegionFlags); }
const std::string getAccessString() const { return LLViewerRegion::accessToString((U8)mAccess); }
const std::string getShortAccessString() const { return LLViewerRegion::accessToShortString(static_cast<U8>(mAccess)); } // <alchemy/>
const std::string getAccessIcon() const { return LLViewerRegion::getAccessIcon(static_cast<U8>(mAccess)); }
const std::string& getAccessString() const { return LLViewerRegion::accessToString((U8)mAccess); }
const std::string& getShortAccessString() const { return LLViewerRegion::accessToShortString(static_cast<U8>(mAccess)); } // <alchemy/>
const std::string& getAccessIcon() const { return LLViewerRegion::getAccessIcon(static_cast<U8>(mAccess)); }
const S32 getAgentCount() const; // Compute the total agents count
LLPointer<LLViewerFetchedTexture> getLandForSaleImage(); // Get the overlay image, fetch it if necessary
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment