diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 26 | ||||
-rw-r--r-- | src/RESearch.cxx | 14 | ||||
-rw-r--r-- | src/RESearch.h | 2 |
3 files changed, 11 insertions, 31 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 2c04bbaae..5d9e10c40 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -3143,11 +3143,6 @@ bool MatchOnLines(const Document *doc, const Regex ®exp, const RESearchRange for (size_t co = 0; co < match.size() && co < RESearch::MAXTAG; co++) { search.bopat[co] = match[co].first.Pos(); search.eopat[co] = match[co].second.PosRoundUp(); - const Sci::Position lenMatch = search.eopat[co] - search.bopat[co]; - search.pat[co].resize(lenMatch); - for (Sci::Position iPos = 0; iPos < lenMatch; iPos++) { - search.pat[co][iPos] = doc->CharAt(iPos + search.bopat[co]); - } } } return matched; @@ -3304,19 +3299,20 @@ Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::P const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) { substituted.clear(); - const DocumentIndexer di(doc, doc->Length()); - search.GrabMatches(di); for (Sci::Position j = 0; j < *length; j++) { if (text[j] == '\\') { - if (text[j + 1] >= '0' && text[j + 1] <= '9') { - const unsigned int patNum = text[j + 1] - '0'; - const Sci::Position len = search.eopat[patNum] - search.bopat[patNum]; - if (!search.pat[patNum].empty()) // Will be null if try for a match that did not occur - substituted.append(search.pat[patNum].c_str(), len); - j++; + const char chNext = text[++j]; + if (chNext >= '0' && chNext <= '9') { + const unsigned int patNum = chNext - '0'; + const Sci::Position startPos = search.bopat[patNum]; + const Sci::Position len = search.eopat[patNum] - startPos; + if (len > 0) { // Will be null if try for a match that did not occur + const size_t size = substituted.length(); + substituted.resize(size + len); + doc->GetCharRange(substituted.data() + size, startPos, len); + } } else { - j++; - switch (text[j]) { + switch (chNext) { case 'a': substituted.push_back('\a'); break; diff --git a/src/RESearch.cxx b/src/RESearch.cxx index 98399c925..8fe3724c8 100644 --- a/src/RESearch.cxx +++ b/src/RESearch.cxx @@ -264,20 +264,6 @@ RESearch::RESearch(CharClassify *charClassTable) { void RESearch::Clear() { bopat.fill(NOTFOUND); eopat.fill(NOTFOUND); - for (int i = 0; i < MAXTAG; i++) { - pat[i].clear(); - } -} - -void RESearch::GrabMatches(const CharacterIndexer &ci) { - for (unsigned int i = 0; i < MAXTAG; i++) { - if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) { - const Sci::Position len = eopat[i] - bopat[i]; - pat[i].resize(len); - for (Sci::Position j = 0; j < len; j++) - pat[i][j] = ci.CharAt(bopat[i] + j); - } - } } void RESearch::ChSet(unsigned char c) noexcept { diff --git a/src/RESearch.h b/src/RESearch.h index c142441ae..37f210e13 100644 --- a/src/RESearch.h +++ b/src/RESearch.h @@ -22,7 +22,6 @@ public: explicit RESearch(CharClassify *charClassTable); // No dynamic allocation so default copy constructor and assignment operator are OK. void Clear(); - void GrabMatches(const CharacterIndexer &ci); const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) noexcept; int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp); @@ -32,7 +31,6 @@ public: using MatchPositions = std::array<Sci::Position, MAXTAG>; MatchPositions bopat; MatchPositions eopat; - std::string pat[MAXTAG]; private: |