mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
highlightFTSResults: return earlier if the regexp is empty
A default-constructed QRegExp is passed to ArticleView::showDefinition() when a user navigates from an FTS-result page by clicking a link or double-clicking a word. QRegExp().pattern() returns an empty string, which is stored in the "regexp" query item of an URL. When this URL is loaded, ArticleView::loadFinished() calls highlightFTSResults(), which then calls closeSearch(), performs multiple string and regular expression operations and early-returns because the regular expression pattern is empty. Returning earlier skips useless work in this case. An alternative optimization is not calling highlightFTSResults() at all when the regular expression is empty, but that would skip the closeSearch() call and keep the FTS search frame visible on a page with an empty regexp.
This commit is contained in:
parent
c936d03fa0
commit
1e43bdf18c
|
@ -2556,9 +2556,10 @@ void ArticleView::highlightFTSResults()
|
|||
|
||||
const QUrl & url = ui.definition->url();
|
||||
|
||||
bool ignoreDiacritics = Qt4x5::Url::hasQueryItem( url, "ignore_diacritics" );
|
||||
|
||||
QString regString = Qt4x5::Url::queryItemValue( url, "regexp" );
|
||||
if( regString.isEmpty() )
|
||||
return;
|
||||
const bool ignoreDiacritics = Qt4x5::Url::hasQueryItem( url, "ignore_diacritics" );
|
||||
if( ignoreDiacritics )
|
||||
regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) );
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue