summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-29 14:28:34 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-29 14:28:34 -0400
commitc06f753d5cf1531c41f0724bb6d4b24d28cec6aa (patch)
treee3dc8fc2405c5c5fa2a87f2802cfdb8056cb5019 /indra
parent4a941ed4a4045fb1099c163b485c5d2a5bd08688 (diff)
Try to eliminate the runtime cost of `ll_convert_to<T>(const T&)`.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llstring.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index b552aede82..c56ef9fb59 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -550,7 +550,13 @@ private:
public:
ll_convert(const FROM& ref): mRef(ref) {}
- template <typename TO>
+ inline operator const FROM&() const
+ {
+ return mRef;
+ }
+
+ template <typename TO,
+ std::enable_if_t<! std::is_same_v<std::decay_t<TO>, std::decay_t<FROM>>, bool> =true>
inline operator TO() const
{
return ll_convert_impl<TO, std::decay_t<const FROM>>()(mRef);
@@ -559,7 +565,15 @@ public:
// When the TO type must be explicit, use a function template to get
// ll_convert_to<TO>(from_value) API.
-template<typename TO, typename FROM>
+template<typename SAME>
+const SAME& ll_convert_to(const SAME& in)
+{
+ return in;
+}
+
+template<typename TO,
+ typename FROM,
+ std::enable_if_t<! std::is_same_v<std::decay_t<TO>, std::decay_t<FROM>>, bool> =true>
TO ll_convert_to(const FROM& in)
{
return ll_convert_impl<TO, std::decay_t<const FROM>>()(in);