From 93ca284badbbfe4e68b201564a2bca5be2b6eaa1 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:47:53 +0800 Subject: [PATCH] opt: refactor code (#1657) * opt: refactor code * [autofix.ci] apply automated fixes * opt: refactor code * opt: refactor code * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/article_maker.cc | 60 +++++++++++++++++++++---------------------- src/fulltextsearch.cc | 9 ------- 2 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/article_maker.cc b/src/article_maker.cc index 2f019adb..6508bcba 100644 --- a/src/article_maker.cc +++ b/src/article_maker.cc @@ -707,40 +707,38 @@ void ArticleRequest::bodyFinished() bodyDone = true; - { - string footer; + string footer; - if ( closePrevSpan ) { - footer += ""; - closePrevSpan = false; - } - - if ( !foundAnyDefinitions ) { - // No definitions were ever found, say so to the user. - - // Larger words are usually whole sentences - don't clutter the output - // with their full bodies. - footer += ArticleMaker::makeNotFoundBody( word.size() < 40 ? word : "", group.name ); - - // When there were no definitions, we run stemmed search. - stemmedWordFinder = std::make_shared< WordFinder >( this ); - - connect( stemmedWordFinder.get(), - &WordFinder::finished, - this, - &ArticleRequest::stemmedSearchFinished, - Qt::QueuedConnection ); - - stemmedWordFinder->stemmedMatch( word, activeDicts ); - } - else { - footer += R"(
)"; - footer += ""; - } - - appendString( footer ); + if ( closePrevSpan ) { + footer += ""; + closePrevSpan = false; } + if ( !foundAnyDefinitions ) { + // No definitions were ever found, say so to the user. + + // Larger words are usually whole sentences - don't clutter the output + // with their full bodies. + footer += ArticleMaker::makeNotFoundBody( word.size() < 40 ? word : word.left( 40 ) + "...", group.name ); + + // When there were no definitions, we run stemmed search. + stemmedWordFinder = std::make_shared< WordFinder >( this ); + + connect( stemmedWordFinder.get(), + &WordFinder::finished, + this, + &ArticleRequest::stemmedSearchFinished, + Qt::QueuedConnection ); + + stemmedWordFinder->stemmedMatch( word, activeDicts ); + } + else { + footer += R"(
)"; + footer += ""; + } + + appendString( footer ); + if ( stemmedWordFinder.get() ) { update(); qDebug() << "send dicts(stemmed):" << hittedWord; diff --git a/src/fulltextsearch.cc b/src/fulltextsearch.cc index dae3ddd0..5f81b471 100644 --- a/src/fulltextsearch.cc +++ b/src/fulltextsearch.cc @@ -8,15 +8,6 @@ #include #include -#include - -#if defined( Q_OS_WIN32 ) - - #include "initializing.hh" - #include - #include - -#endif #include "globalregex.hh" namespace FTS {