diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-07-09 17:03:22 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-07-09 17:03:22 +1000 |
| commit | cd67f2cf113704fce973ce7139f8cdac2561c139 (patch) | |
| tree | f61a04fdaae36ee0918aa7f7242702c5bd560d33 /src/optional.hh | |
| parent | cac946b43470c5769d2cd265934829b7121ecd9b (diff) | |
Avoid copying token content strings in expand_token
We can move that data instead of copying
Diffstat (limited to 'src/optional.hh')
| -rw-r--r-- | src/optional.hh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/optional.hh b/src/optional.hh index 8531042e..e9386fa8 100644 --- a/src/optional.hh +++ b/src/optional.hh @@ -68,12 +68,20 @@ public: return m_value; } - T& operator*() + T& operator*() & { kak_assert(m_valid); return m_value; } - const T& operator*() const { return *const_cast<Optional&>(*this); } + + T&& operator*() && + { + kak_assert(m_valid); + return std::move(m_value); + } + + const T& operator*() const & { return *const_cast<Optional&>(*this); } + const T& operator*() const && { return *const_cast<Optional&>(*this); } T* operator->() { |
