diff options
author | Neil <nyamatongwe@gmail.com> | 2019-03-29 09:05:14 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2019-03-29 09:05:14 +1100 |
commit | 6d1bf18357b56cbec7d289c9c9434a7a8888b386 (patch) | |
tree | e03227ff253d79d62c42b331c2b66d32b81dc9c0 /lexlib/CharacterCategory.h | |
parent | 62b31d42a2ee02b4992134d325fab6f297729094 (diff) | |
download | scintilla-mirror-6d1bf18357b56cbec7d289c9c9434a7a8888b386.tar.gz |
Feature [feature-requests:#1259]. Add SCI_SETCHARACTERCATEGORYOPTIMIZATION API
to optimize speed of character category features.
Diffstat (limited to 'lexlib/CharacterCategory.h')
-rw-r--r-- | lexlib/CharacterCategory.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lexlib/CharacterCategory.h b/lexlib/CharacterCategory.h index 767d79670..d1ac39152 100644 --- a/lexlib/CharacterCategory.h +++ b/lexlib/CharacterCategory.h @@ -28,6 +28,23 @@ bool IsIdContinue(int character); bool IsXidStart(int character); bool IsXidContinue(int character); +class CharacterCategoryMap { +private: + std::vector<unsigned char> dense; +public: + CharacterCategoryMap() noexcept; + CharacterCategory CategoryFor(int character) const { + if (static_cast<size_t>(character) < dense.size()) { + return static_cast<CharacterCategory>(dense[character]); + } else { + // binary search through ranges + return CategoriseCharacter(character); + } + } + int Size() const noexcept; + void Optimize(int countCharacters); +}; + } #endif |