summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2010-04-20 17:05:49 -0700
committerJames Cook <james@lindenlab.com>2010-04-20 17:05:49 -0700
commit022a598694cd37bebff3322054324c7d27afd5ff (patch)
tree81fbb61a86ee00c8b3287eaedd7da2af39da188f /indra/llcommon
parent257c3ed2a3747256500f704f6e06e7631af3c08e (diff)
Viewer caches avatar display names between sessions
Reviewed with Simon
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llavatarname.cpp25
-rw-r--r--indra/llcommon/llavatarname.h8
2 files changed, 32 insertions, 1 deletions
diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp
index 5debf88818..62ba7cb112 100644
--- a/indra/llcommon/llavatarname.cpp
+++ b/indra/llcommon/llavatarname.cpp
@@ -35,6 +35,13 @@
#include "llavatarname.h"
+// Store these in pre-built std::strings to avoid memory allocations in
+// LLSD map lookups
+static const std::string SL_ID("sl_id");
+static const std::string DISPLAY_NAME("display_name");
+static const std::string IS_DISPLAY_NAME_DEFAULT("is_display_name_default");
+static const std::string EXPIRES("expires");
+
LLAvatarName::LLAvatarName()
: mSLID(),
mDisplayName(),
@@ -50,3 +57,21 @@ bool LLAvatarName::operator<(const LLAvatarName& rhs) const
else
return mSLID < rhs.mSLID;
}
+
+LLSD LLAvatarName::asLLSD() const
+{
+ LLSD sd;
+ sd[SL_ID] = mSLID;
+ sd[DISPLAY_NAME] = mDisplayName;
+ sd[IS_DISPLAY_NAME_DEFAULT] = mIsDisplayNameDefault;
+ sd[EXPIRES] = mExpires;
+ return sd;
+}
+
+void LLAvatarName::fromLLSD(const LLSD& sd)
+{
+ mSLID = sd[SL_ID].asString();
+ mDisplayName = sd[DISPLAY_NAME].asString();
+ mIsDisplayNameDefault = sd[IS_DISPLAY_NAME_DEFAULT].asBoolean();
+ mExpires = sd[EXPIRES].asReal();
+}
diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h
index 72e2980b5c..11bd5f30b7 100644
--- a/indra/llcommon/llavatarname.h
+++ b/indra/llcommon/llavatarname.h
@@ -36,13 +36,19 @@
#include <string>
+class LLSD;
+
class LL_COMMON_API LLAvatarName
{
public:
LLAvatarName();
-
+
bool operator<(const LLAvatarName& rhs) const;
+ LLSD asLLSD() const;
+
+ void fromLLSD(const LLSD& sd);
+
// "bobsmith123" or "james.linden", US-ASCII only
std::string mSLID;