Improve performance for "Find in Files" and ""Find all in..."
Fix #11878, close #12048pull/12059/head
parent
9809e2fc2c
commit
adcace3380
|
@ -664,15 +664,18 @@ vector<generic_string> Finder::getResultFilePaths() const
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Finder::canFind(const TCHAR *fileName, size_t lineNumber) const
|
bool Finder::canFind(const TCHAR *fileName, size_t lineNumber, size_t* indexToStartFrom) const
|
||||||
{
|
{
|
||||||
size_t len = _pMainFoundInfos->size();
|
size_t len = _pMainFoundInfos->size();
|
||||||
for (size_t i = 0; i < len; ++i)
|
for (size_t i = *indexToStartFrom; i < len; ++i)
|
||||||
{
|
{
|
||||||
if ((*_pMainFoundInfos)[i]._fullPath == fileName)
|
if ((*_pMainFoundInfos)[i]._fullPath == fileName)
|
||||||
{
|
{
|
||||||
if (lineNumber == (*_pMainFoundInfos)[i]._lineNumber)
|
if (lineNumber == (*_pMainFoundInfos)[i]._lineNumber)
|
||||||
|
{
|
||||||
|
*indexToStartFrom = i;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2738,6 +2741,10 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
|
|
||||||
bool findAllFileNameAdded = false;
|
bool findAllFileNameAdded = false;
|
||||||
|
|
||||||
|
// A temporary string which is used to populate the search result window
|
||||||
|
std::unique_ptr<std::string> text2AddUtf8(new std::string());
|
||||||
|
size_t indexBuffer = 0;
|
||||||
|
|
||||||
while (targetStart >= 0)
|
while (targetStart >= 0)
|
||||||
{
|
{
|
||||||
targetStart = pEditView->searchInTarget(pTextFind, stringSizeFind, findReplaceInfo._startRange, findReplaceInfo._endRange);
|
targetStart = pEditView->searchInTarget(pTextFind, stringSizeFind, findReplaceInfo._startRange, findReplaceInfo._endRange);
|
||||||
|
@ -2794,8 +2801,15 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
|
|
||||||
SearchResultMarkingLine srml;
|
SearchResultMarkingLine srml;
|
||||||
srml._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(start_mark, end_mark));
|
srml._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(start_mark, end_mark));
|
||||||
_pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srml, line.c_str(), totalLineNumber);
|
text2AddUtf8->append(_pFinder->foundLine(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srml, line.c_str(), totalLineNumber));
|
||||||
|
|
||||||
|
if (text2AddUtf8->length() > FINDTEMPSTRING_MAXSIZE)
|
||||||
|
{
|
||||||
|
_pFinder->setFinderReadOnly(false);
|
||||||
|
_pFinder->_scintView.execute(SCI_ADDTEXT, text2AddUtf8->length(), reinterpret_cast<LPARAM>(text2AddUtf8->c_str()));
|
||||||
|
_pFinder->setFinderReadOnly(true);
|
||||||
|
text2AddUtf8->clear();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2828,7 +2842,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
SearchResultMarkingLine srml;
|
SearchResultMarkingLine srml;
|
||||||
srml._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(start_mark, end_mark));
|
srml._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(start_mark, end_mark));
|
||||||
|
|
||||||
processed = (!pOptions->_isMatchLineNumber) || (pFindersInfo->_pSourceFinder->canFind(pFileName, lineNumber + 1));
|
processed = (!pOptions->_isMatchLineNumber) || (pFindersInfo->_pSourceFinder->canFind(pFileName, lineNumber + 1, &indexBuffer));
|
||||||
if (processed)
|
if (processed)
|
||||||
{
|
{
|
||||||
if (!findAllFileNameAdded) //add new filetitle in hits if we haven't already
|
if (!findAllFileNameAdded) //add new filetitle in hits if we haven't already
|
||||||
|
@ -2836,7 +2850,15 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
pFindersInfo->_pDestFinder->addFileNameTitle(pFileName);
|
pFindersInfo->_pDestFinder->addFileNameTitle(pFileName);
|
||||||
findAllFileNameAdded = true;
|
findAllFileNameAdded = true;
|
||||||
}
|
}
|
||||||
pFindersInfo->_pDestFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srml, line.c_str(), totalLineNumber);
|
text2AddUtf8->append(pFindersInfo->_pDestFinder->foundLine(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srml, line.c_str(), totalLineNumber));
|
||||||
|
|
||||||
|
if (text2AddUtf8->length() > FINDTEMPSTRING_MAXSIZE)
|
||||||
|
{
|
||||||
|
pFindersInfo->_pDestFinder->setFinderReadOnly(false);
|
||||||
|
pFindersInfo->_pDestFinder->_scintView.execute(SCI_ADDTEXT, text2AddUtf8->length(), reinterpret_cast<LPARAM>(text2AddUtf8->c_str()));
|
||||||
|
pFindersInfo->_pDestFinder->setFinderReadOnly(true);
|
||||||
|
text2AddUtf8->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2947,12 +2969,22 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
Finder *pFinder = nullptr;
|
Finder *pFinder = nullptr;
|
||||||
if (op == ProcessFindAll)
|
if (op == ProcessFindAll)
|
||||||
{
|
{
|
||||||
|
_pFinder->setFinderReadOnly(false);
|
||||||
|
_pFinder->_scintView.execute(SCI_ADDTEXT, text2AddUtf8->length(), reinterpret_cast<LPARAM>(text2AddUtf8->c_str()));
|
||||||
|
_pFinder->setFinderReadOnly(true);
|
||||||
|
text2AddUtf8->clear();
|
||||||
pFinder = _pFinder;
|
pFinder = _pFinder;
|
||||||
}
|
}
|
||||||
else if (op == ProcessFindInFinder)
|
else if (op == ProcessFindInFinder)
|
||||||
{
|
{
|
||||||
if (pFindersInfo && pFindersInfo->_pDestFinder)
|
if (pFindersInfo && pFindersInfo->_pDestFinder)
|
||||||
|
{
|
||||||
|
pFindersInfo->_pDestFinder->setFinderReadOnly(false);
|
||||||
|
pFindersInfo->_pDestFinder->_scintView.execute(SCI_ADDTEXT, text2AddUtf8->length(), reinterpret_cast<LPARAM>(text2AddUtf8->c_str()));
|
||||||
|
pFindersInfo->_pDestFinder->setFinderReadOnly(true);
|
||||||
|
text2AddUtf8->clear();
|
||||||
pFinder = pFindersInfo->_pDestFinder;
|
pFinder = pFindersInfo->_pDestFinder;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pFinder = _pFinder;
|
pFinder = _pFinder;
|
||||||
}
|
}
|
||||||
|
@ -4467,7 +4499,7 @@ void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines,
|
||||||
setFinderReadOnly(true);
|
setFinderReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Finder::add(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foundline, size_t totalLineNumber)
|
const char* Finder::foundLine(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foundline, size_t totalLineNumber)
|
||||||
{
|
{
|
||||||
bool isRepeatedLine = false;
|
bool isRepeatedLine = false;
|
||||||
|
|
||||||
|
@ -4514,6 +4546,7 @@ void Finder::add(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foun
|
||||||
// Add start and end markers into the previous line's info for colourizing
|
// Add start and end markers into the previous line's info for colourizing
|
||||||
_pMainMarkings->back()._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(miLine._segmentPostions[0].first, miLine._segmentPostions[0].second));
|
_pMainMarkings->back()._segmentPostions.push_back(std::pair<intptr_t, intptr_t>(miLine._segmentPostions[0].first, miLine._segmentPostions[0].second));
|
||||||
_pMainFoundInfos->back()._ranges.push_back(fi._ranges.back());
|
_pMainFoundInfos->back()._ranges.push_back(fi._ranges.back());
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
else // default mode: allow same found line has several entries in search result if the searched occurrence is matched several times in the same line
|
else // default mode: allow same found line has several entries in search result if the searched occurrence is matched several times in the same line
|
||||||
{
|
{
|
||||||
|
@ -4533,10 +4566,9 @@ void Finder::add(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foun
|
||||||
len = cut + lenEndOfLongLine;
|
len = cut + lenEndOfLongLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFinderReadOnly(false);
|
|
||||||
_scintView.execute(SCI_ADDTEXT, len, reinterpret_cast<LPARAM>(text2AddUtf8));
|
|
||||||
setFinderReadOnly(true);
|
|
||||||
_pMainMarkings->push_back(miLine);
|
_pMainMarkings->push_back(miLine);
|
||||||
|
|
||||||
|
return text2AddUtf8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define FINDREPLACE_MAXLENGTH 2048
|
#define FINDREPLACE_MAXLENGTH 2048
|
||||||
|
|
||||||
|
#define FINDTEMPSTRING_MAXSIZE 1024*1024
|
||||||
|
|
||||||
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, FINDINPROJECTS_DLG, MARK_DLG};
|
enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, FINDINPROJECTS_DLG, MARK_DLG};
|
||||||
|
|
||||||
#define DIR_DOWN true
|
#define DIR_DOWN true
|
||||||
|
@ -121,7 +123,7 @@ public:
|
||||||
void addFileNameTitle(const TCHAR * fileName);
|
void addFileNameTitle(const TCHAR * fileName);
|
||||||
void addFileHitCount(int count);
|
void addFileHitCount(int count);
|
||||||
void addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection);
|
void addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection);
|
||||||
void add(FoundInfo fi, SearchResultMarkingLine mi, const TCHAR* foundline, size_t totalLineNumber);
|
const char* foundLine(FoundInfo fi, SearchResultMarkingLine mi, const TCHAR* foundline, size_t totalLineNumber);
|
||||||
void setFinderStyle();
|
void setFinderStyle();
|
||||||
void removeAll();
|
void removeAll();
|
||||||
void openAll();
|
void openAll();
|
||||||
|
@ -136,7 +138,7 @@ public:
|
||||||
std::pair<intptr_t, intptr_t> gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used
|
std::pair<intptr_t, intptr_t> gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used
|
||||||
void deleteResult();
|
void deleteResult();
|
||||||
std::vector<generic_string> getResultFilePaths() const;
|
std::vector<generic_string> getResultFilePaths() const;
|
||||||
bool canFind(const TCHAR *fileName, size_t lineNumber) const;
|
bool canFind(const TCHAR *fileName, size_t lineNumber, size_t* indexToStartFrom) const;
|
||||||
void setVolatiled(bool val) { _canBeVolatiled = val; };
|
void setVolatiled(bool val) { _canBeVolatiled = val; };
|
||||||
generic_string getHitsString(int count) const;
|
generic_string getHitsString(int count) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue