From 8a751e1b57b07ff43739e69f395ee4dfc3431ba0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 1 Nov 2018 21:05:09 +1100 Subject: [PATCH] Remove caching from utf8_iterator --- src/utf8_iterator.hh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh index 9d10df2af..0467c30e3 100644 --- a/src/utf8_iterator.hh +++ b/src/utf8_iterator.hh @@ -38,7 +38,6 @@ public: iterator& operator++() noexcept { utf8::to_next(m_it, m_end); - invalidate_value(); return *this; } @@ -52,7 +51,6 @@ public: iterator& operator--() noexcept { utf8::to_previous(m_it, m_begin); - invalidate_value(); return *this; } @@ -127,7 +125,7 @@ public: CodepointType operator*() const noexcept(noexcept_policy) { - return get_value(); + return (CodepointType)utf8::codepoint(m_it, m_end); } CodepointType read() noexcept(noexcept_policy) @@ -138,18 +136,9 @@ public: const BaseIt& base() const noexcept(noexcept_policy) { return m_it; } private: - void invalidate_value() noexcept { m_value = -1; } - CodepointType get_value() const noexcept(noexcept_policy) - { - if (m_value == (CodepointType)-1) - m_value = (CodepointType)utf8::codepoint(m_it, m_end); - return m_value; - } - BaseIt m_it; Sentinel m_begin; Sentinel m_end; - mutable CodepointType m_value = -1; }; }