summaryrefslogtreecommitdiffhomepage
path: root/options/value.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:34:07 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:34:07 +0100
commit57d8fa7661c97fb9f02279060694a0073e7cc8b5 (patch)
treefef806825c73b9da2b0fad458a0c4488e756ff60 /options/value.hpp
parent4acd40cd2997b2702d9ab411a0c85d1a92a6189d (diff)
options: get element with call operator
thread_local is expensive.
Diffstat (limited to 'options/value.hpp')
-rw-r--r--options/value.hpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/options/value.hpp b/options/value.hpp
index 3c45bf15..01746d67 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -166,14 +166,6 @@ public:
{
}
- t get() const
- {
- t val = b->contains(self_name)
- ? static_cast<t>(b->get<element_type>(self_name))
- : def;
- return detail::value_get_traits<t>::get(val, def);
- }
-
t default_value() const
{
return def;
@@ -191,13 +183,20 @@ public:
emit valueChanged(static_cast<detail::value_type_t<t>>(get()));
}
- element_type const* operator->() const
+ element_type operator()() const
{
- static thread_local element_type last;
- last = get();
- return &last;
+ return get();
}
+
private:
+ t get() const
+ {
+ t val = b->contains(self_name)
+ ? static_cast<t>(b->get<element_type>(self_name))
+ : def;
+ return detail::value_get_traits<t>::get(val, def);
+ }
+
const t def;
};