From 946a38cf14ff718b637755292693920f380f0e61 Mon Sep 17 00:00:00 2001 From: Xiao Yi Fang Date: Mon, 24 Jun 2024 11:10:37 +0800 Subject: [PATCH] opt: respect maxResult parameter --- src/btreeidx.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/btreeidx.cc b/src/btreeidx.cc index bc1d44470..dbabbe1c9 100644 --- a/src/btreeidx.cc +++ b/src/btreeidx.cc @@ -290,15 +290,15 @@ void BtreeWordSearchRequest::findMatches() || (int)resultFolded.size() - initialFoldedSize <= maxSuffixVariation ) ) addMatch( Utf8::decode( x.prefix + x.word ) ); } + if ( matches.size() >= maxResults ) { + break; + } } if ( Utils::AtomicInt::loadAcquire( isCancelled ) ) break; 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; } }