mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
opt: respect maxResult parameter (#1611)
* opt: respect maxResult parameter * opt: respect maxResult parameter * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
2b9d17251b
commit
c82db14ea7
|
@ -272,6 +272,9 @@ void BtreeWordSearchRequest::findMatches()
|
||||||
QMutexLocker _( &dataMutex );
|
QMutexLocker _( &dataMutex );
|
||||||
|
|
||||||
for ( auto & x : chain ) {
|
for ( auto & x : chain ) {
|
||||||
|
if ( Utils::AtomicInt::loadAcquire( isCancelled ) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if ( useWildcards ) {
|
if ( useWildcards ) {
|
||||||
wstring word = Utf8::decode( x.prefix + x.word );
|
wstring word = Utf8::decode( x.prefix + x.word );
|
||||||
wstring result = Folding::applyDiacriticsOnly( word );
|
wstring result = Folding::applyDiacriticsOnly( word );
|
||||||
|
@ -290,15 +293,15 @@ void BtreeWordSearchRequest::findMatches()
|
||||||
|| (int)resultFolded.size() - initialFoldedSize <= maxSuffixVariation ) )
|
|| (int)resultFolded.size() - initialFoldedSize <= maxSuffixVariation ) )
|
||||||
addMatch( Utf8::decode( x.prefix + x.word ) );
|
addMatch( Utf8::decode( x.prefix + x.word ) );
|
||||||
}
|
}
|
||||||
|
if ( matches.size() >= maxResults ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Utils::AtomicInt::loadAcquire( isCancelled ) )
|
if ( Utils::AtomicInt::loadAcquire( isCancelled ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( matches.size() >= maxResults ) {
|
if ( matches.size() >= maxResults ) {
|
||||||
// For now we actually allow more than maxResults if the last
|
|
||||||
// chain yield more than one result. That's ok and maybe even more
|
|
||||||
// desirable.
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue