diff options
author | Zufu Liu <unknown> | 2023-11-02 08:51:15 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-11-02 08:51:15 +1100 |
commit | e702dacda85f0976d1006d9634dc38b53fad1336 (patch) | |
tree | 76b1f6005d0a645f702fc2c750f3d7626bea3da0 /src/Document.cxx | |
parent | 4c06fe443f2dd9d6235c9cf95d38f7054cfd82b2 (diff) | |
download | scintilla-mirror-e702dacda85f0976d1006d9634dc38b53fad1336.tar.gz |
Feature [feature-requests:#1500] Remove match text retrieval from MatchOnLines
as it is redone in SubstituteByPosition.
Replace RESearch::pat and RESearch::GrabMatches with retrieving matches as
needed in SubstituteByPosition.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 26 |
1 files changed, 11 insertions, 15 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; |