diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-04-02 17:45:11 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-04-02 17:45:11 +1100 |
| commit | 424a7ee8aaaa5ac23355bcabcebf485e6a63c9c3 (patch) | |
| tree | 2fa83399ec7fa40764f8c03d87fb0dfba9cc6ba9 | |
| parent | 63efcc06d5bee7f05a1ee9539b2391c80e5d6205 (diff) | |
Reduce include creep
| -rw-r--r-- | src/ranked_match.cc | 4 | ||||
| -rw-r--r-- | src/regex_impl.cc | 1 | ||||
| -rw-r--r-- | src/utf8.hh | 12 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/ranked_match.cc b/src/ranked_match.cc index 6918809c..db6f9328 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -261,8 +261,8 @@ bool RankedMatch::operator<(const RankedMatch& other) const const auto cp2 = utf8::read_codepoint(it2, end2); if (cp1 != cp2) { - const auto cplast1 = utf8::prev_codepoint(itsave1, begin1).value_or(Codepoint{0}); - const auto cplast2 = utf8::prev_codepoint(itsave2, begin2).value_or(Codepoint{0}); + const auto cplast1 = utf8::prev_codepoint(itsave1, begin1); + const auto cplast2 = utf8::prev_codepoint(itsave2, begin2); const bool is_wb1 = is_word_boundary(cplast1, cp1); const bool is_wb2 = is_word_boundary(cplast2, cp2); if (is_wb1 != is_wb2) diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 0789ef6d..dd900125 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -6,6 +6,7 @@ #include "utf8.hh" #include "utf8_iterator.hh" #include "format.hh" +#include "optional.hh" #include "vector.hh" #include "utils.hh" #include "ranges.hh" diff --git a/src/utf8.hh b/src/utf8.hh index e5643214..12be2861 100644 --- a/src/utf8.hh +++ b/src/utf8.hh @@ -4,7 +4,6 @@ #include "assert.hh" #include "unicode.hh" #include "units.hh" -#include "optional.hh" namespace Kakoune { @@ -263,14 +262,13 @@ Iterator character_start(Iterator it, const Sentinel& begin) noexcept return it; } -// returns an optional iterator to the first byte of the previous character -// or no value if it is at begin -template<typename Iterator, typename Sentinel> -static Optional<Codepoint> prev_codepoint(Iterator it, const Sentinel& begin) noexcept +template<typename InvalidPolicy = utf8::InvalidPolicy::Pass, + typename Iterator, typename Sentinel> +Codepoint prev_codepoint(Iterator it, const Sentinel& begin) noexcept { if (it <= begin) - return {}; - return codepoint(character_start(it -1, begin), it); + return InvalidPolicy{}(-1); + return codepoint<InvalidPolicy>(character_start(it -1, begin), it); } |
