aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2021-04-03 10:01:23 +1100
committerZufu Liu <unknown>2021-04-03 10:01:23 +1100
commit78601728e07170bb6389625e9a4013e6e0aac223 (patch)
tree70a01dc1a3e836b162d349fcbc31951779d701a2
parent048b333709c826a4f9f2bbdfc36734d6425c54ba (diff)
downloadscintilla-mirror-78601728e07170bb6389625e9a4013e6e0aac223.tar.gz
Feature [feature-requests:#1392]. Minor optimizations of RESearch.
-rw-r--r--src/RESearch.cxx23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 262483d88..54815d0a3 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -237,11 +237,8 @@ using namespace Scintilla;
* The following defines are not meant to be changeable.
* They are for readability only.
*/
-#define BLKIND 0370
#define BITIND 07
-static const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' };
-
#define badpat(x) (*nfa = END, x)
/*
@@ -287,7 +284,7 @@ void RESearch::GrabMatches(const CharacterIndexer &ci) {
}
void RESearch::ChSet(unsigned char c) noexcept {
- bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
+ bittab[c >> 3] |= 1 << (c & BITIND);
}
void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) noexcept {
@@ -301,7 +298,9 @@ void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) noexcept {
}
}
-static unsigned char escapeValue(unsigned char ch) noexcept {
+namespace {
+
+constexpr unsigned char escapeValue(unsigned char ch) noexcept {
switch (ch) {
case 'a': return '\a';
case 'b': return '\b';
@@ -314,7 +313,7 @@ static unsigned char escapeValue(unsigned char ch) noexcept {
return 0;
}
-static int GetHexaChar(unsigned char hd1, unsigned char hd2) noexcept {
+constexpr int GetHexaChar(unsigned char hd1, unsigned char hd2) noexcept {
int hexValue = 0;
if (hd1 >= '0' && hd1 <= '9') {
hexValue += 16 * (hd1 - '0');
@@ -337,6 +336,12 @@ static int GetHexaChar(unsigned char hd1, unsigned char hd2) noexcept {
return hexValue;
}
+constexpr int isinset(const char *ap, unsigned char c) noexcept {
+ return ap[c >> 3] & (1 << (c & BITIND));
+}
+
+}
+
/**
* Called when the parser finds a backslash not followed
* by a valid expression (like \( in non-Posix mode).
@@ -829,11 +834,7 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio
* by tagged expressions (n = 1 to 9).
*/
-extern void re_fail(char *,char);
-
-static inline int isinset(const char *ap, unsigned char c) noexcept {
- return ap[(c & BLKIND) >> 3] & bitarr[c & BITIND];
-}
+//extern void re_fail(char *,char);
/*
* skip values for CLO XXX to skip past the closure