diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-03-22 19:54:25 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-03-22 19:54:25 +1100 |
| commit | 2dd69b3d967aea4715746d827b88436822bfc41f (patch) | |
| tree | 7b6f1a419c50ebb43d0c867356d620eca82d0fb3 /src | |
| parent | 794e7ce51c7b2256ebc98cf8b7c8d4291dcba382 (diff) | |
Make CompiledRegex not a RefCountable
Keep this closer to the point of use, avoid pull ref_ptr.hpp into
regex_impl.hpp
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.cc | 4 | ||||
| -rw-r--r-- | src/regex.hh | 5 | ||||
| -rw-r--r-- | src/regex_impl.hh | 3 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/regex.cc b/src/regex.cc index df5af661..b62bdddf 100644 --- a/src/regex.cc +++ b/src/regex.cc @@ -6,10 +6,10 @@ namespace Kakoune { Regex::Regex(StringView re, RegexCompileFlags flags) - : m_impl{new CompiledRegex{}}, + : m_impl{new Impl{}}, m_str{re.str()} { - *m_impl = compile_regex(re, flags); + static_cast<CompiledRegex&>(*m_impl) = compile_regex(re, flags); } int Regex::named_capture_index(StringView name) const diff --git a/src/regex.hh b/src/regex.hh index c0f3970e..c65ba60c 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -3,6 +3,7 @@ #include "string.hh" #include "regex_impl.hh" +#include "ref_ptr.hh" namespace Kakoune { @@ -27,7 +28,9 @@ public: const CompiledRegex* impl() const { return m_impl.get(); } private: - RefPtr<CompiledRegex> m_impl; + struct Impl : RefCountable, CompiledRegex {}; + + RefPtr<Impl> m_impl; String m_str; }; diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 8f11f1af..d8df2255 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -3,7 +3,6 @@ #include "exception.hh" #include "flags.hh" -#include "ref_ptr.hh" #include "unicode.hh" #include "utf8.hh" #include "vector.hh" @@ -66,7 +65,7 @@ struct CharacterClass }; -struct CompiledRegex : RefCountable, UseMemoryDomain<MemoryDomain::Regex> +struct CompiledRegex : UseMemoryDomain<MemoryDomain::Regex> { enum Op : char { |
