stardict_lib: remove dead poGet{Current,Next,Pre}Word iterators

They aren't used at all by scdv, and thus aren't tested (meaning that
adaptions to the core lookup algorithms can be complicated because these
methods use them but aren't tested so there's no real way of knowing if
a change has broken the methods or not).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai
2021-11-03 18:19:39 +11:00
committed by Evgeniy Dushistov
parent 6d385221d0
commit 4a9b1dae3d
2 changed files with 0 additions and 130 deletions

View File

@@ -1037,133 +1037,6 @@ void Libs::load(const std::list<std::string> &dicts_dirs,
}); });
} }
const gchar *Libs::poGetCurrentWord(glong *iCurrent)
{
const gchar *poCurrentWord = nullptr;
const gchar *word;
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
if (iCurrent[iLib] == INVALID_INDEX)
continue;
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
continue;
if (poCurrentWord == nullptr) {
poCurrentWord = poGetWord(iCurrent[iLib], iLib);
} else {
word = poGetWord(iCurrent[iLib], iLib);
if (stardict_strcmp(poCurrentWord, word) > 0)
poCurrentWord = word;
}
}
return poCurrentWord;
}
const gchar *Libs::poGetNextWord(const gchar *sWord, glong *iCurrent)
{
// the input can be:
// (word,iCurrent),read word,write iNext to iCurrent,and return next word. used by TopWin::NextCallback();
// (nullptr,iCurrent),read iCurrent,write iNext to iCurrent,and return next word. used by AppCore::ListWords();
const gchar *poCurrentWord = nullptr;
size_t iCurrentLib = 0;
const gchar *word;
glong nextWordIdx = 0;
std::set<glong> wordIndices;
for (size_t iLib = 0; iLib < oLib.size(); ++iLib) {
wordIndices.clear();
if (sWord) {
if (oLib[iLib]->Lookup(sWord, wordIndices, nextWordIdx)) {
// In order to progress over words which have multiple entries,
// pick the smallest index larger than iCurrent.
for (auto &wordIdx : wordIndices) {
if (wordIdx > iCurrent[iLib]) {
iCurrent[iLib] = wordIdx;
break;
}
}
} else {
iCurrent[iLib] = nextWordIdx;
}
}
if (iCurrent[iLib] == INVALID_INDEX)
continue;
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
continue;
if (poCurrentWord == nullptr) {
poCurrentWord = poGetWord(iCurrent[iLib], iLib);
iCurrentLib = iLib;
} else {
word = poGetWord(iCurrent[iLib], iLib);
if (stardict_strcmp(poCurrentWord, word) > 0) {
poCurrentWord = word;
iCurrentLib = iLib;
}
}
}
if (poCurrentWord) {
iCurrent[iCurrentLib]++;
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
if (iLib == iCurrentLib)
continue;
if (iCurrent[iLib] == INVALID_INDEX)
continue;
if (iCurrent[iLib] >= narticles(iLib) || iCurrent[iLib] < 0)
continue;
if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib], iLib)) == 0)
iCurrent[iLib]++;
}
poCurrentWord = poGetCurrentWord(iCurrent);
}
return poCurrentWord;
}
const gchar *
Libs::poGetPreWord(glong *iCurrent)
{
// used by TopWin::PreviousCallback(); the iCurrent is cached by AppCore::TopWinWordChange();
const gchar *poCurrentWord = nullptr;
std::vector<Dict *>::size_type iCurrentLib = 0;
const gchar *word;
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
if (iCurrent[iLib] == INVALID_INDEX)
iCurrent[iLib] = narticles(iLib);
else {
if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0)
continue;
}
if (poCurrentWord == nullptr) {
poCurrentWord = poGetWord(iCurrent[iLib] - 1, iLib);
iCurrentLib = iLib;
} else {
word = poGetWord(iCurrent[iLib] - 1, iLib);
if (stardict_strcmp(poCurrentWord, word) < 0) {
poCurrentWord = word;
iCurrentLib = iLib;
}
}
}
if (poCurrentWord) {
iCurrent[iCurrentLib]--;
for (std::vector<Dict *>::size_type iLib = 0; iLib < oLib.size(); iLib++) {
if (iLib == iCurrentLib)
continue;
if (iCurrent[iLib] > narticles(iLib) || iCurrent[iLib] <= 0)
continue;
if (strcmp(poCurrentWord, poGetWord(iCurrent[iLib] - 1, iLib)) == 0) {
iCurrent[iLib]--;
} else {
if (iCurrent[iLib] == narticles(iLib))
iCurrent[iLib] = INVALID_INDEX;
}
}
}
return poCurrentWord;
}
bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib) bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib)
{ {
bool bFound = false; bool bFound = false;

View File

@@ -195,9 +195,6 @@ public:
return nullptr; return nullptr;
return oLib[iLib]->get_data(iIndex); return oLib[iLib]->get_data(iIndex);
} }
const gchar *poGetCurrentWord(glong *iCurrent);
const gchar *poGetNextWord(const gchar *word, glong *iCurrent);
const gchar *poGetPreWord(glong *iCurrent);
bool LookupWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib) bool LookupWord(const gchar *sWord, std::set<glong> &iWordIndices, int iLib)
{ {
return oLib[iLib]->Lookup(sWord, iWordIndices); return oLib[iLib]->Lookup(sWord, iWordIndices);