diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-08-29 23:56:22 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-08-29 23:56:22 +0100 |
| commit | cbe38b2f962443f5fefcbbb5f7552f50c0e841fc (patch) | |
| tree | 85a82f0afb84a5cc217bcefd336c5c81989a55ee /src/ranked_match.hh | |
| parent | 95c21a4ebd60c8f52f0b6dea2bb82f9ae6b0014d (diff) | |
Use flags and bit operations instead of bools in RankedMatch
full match is now the most important flag for comparison.
Diffstat (limited to 'src/ranked_match.hh')
| -rw-r--r-- | src/ranked_match.hh | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ranked_match.hh b/src/ranked_match.hh index 0e0e49c4..35d76e15 100644 --- a/src/ranked_match.hh +++ b/src/ranked_match.hh @@ -2,6 +2,7 @@ #define ranked_match_hh_INCLUDED #include "string.hh" +#include "flags.hh" namespace Kakoune { @@ -32,14 +33,24 @@ private: template<typename TestFunc> RankedMatch(StringView candidate, StringView query, TestFunc test); + enum class Flags : int + { + None = 0, + // Order is important, the highest bit has precedence for comparison + OnlyWordBoundary = 1 << 0, + FirstCharMatch = 1 << 1, + Prefix = 1 << 2, + FullMatch = 1 << 3, + }; + StringView m_candidate; - bool m_first_char_match = false; - bool m_prefix = false; + Flags m_flags = Flags::None; int m_word_boundary_match_count = 0; int m_match_index_sum = 0; - bool m_only_word_boundary = false; }; +template<> struct WithBitOps<RankedMatch::Flags> : std::true_type {}; + } #endif // ranked_match_hh_INCLUDED |
