From 53ce63fbf512e001bd2f1695ba1dbe65a492ba2b Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 5 Oct 2022 15:05:04 +0800 Subject: [PATCH 1/2] fix:epwing performance improvement. the head correction process seems takes too much time. The headword is returned by epwing api , there is no need to verify the headword again . And at some cases , the headword verification never works. --- epwing_book.cc | 44 +++++++++++++++++++++++--------------------- folding.cc | 2 +- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/epwing_book.cc b/epwing_book.cc index f6eed69c..2e89be1d 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -1032,42 +1032,44 @@ void EpwingBook::fixHeadword( QString & headword ) headword.remove( QChar( 0x30FB ) ); // Used in Japan transcription - if( isHeadwordCorrect( headword) ) - return; + //if( isHeadwordCorrect( headword) ) + // return; QString fixed = headword; QRegularExpression leadingSlashRx( "/[^/]+/" ); fixed.remove(leadingSlashRx ); - if( isHeadwordCorrect( fixed ) ) - { - headword = fixed; - return; - } + //if( isHeadwordCorrect( fixed ) ) + //{ + // headword = fixed; + // return; + //} gd::wstring folded = Folding::applyPunctOnly( gd::toWString( fixed ) ); fixed = gd::toQString( folded ); - if( isHeadwordCorrect( fixed ) ) - { - headword = fixed; - return; - } + //if( isHeadwordCorrect( fixed ) ) + //{ + // headword = fixed; + // return; + //} folded = Folding::applyDiacriticsOnly( folded ); fixed = gd::toQString( folded ); - if( isHeadwordCorrect( fixed ) ) - { - headword = fixed; - return; - } + //if( isHeadwordCorrect( fixed ) ) + //{ + // headword = fixed; + // return; + //} - folded = Folding::applyWhitespaceOnly( folded ); - fixed = gd::toQString( folded ); + //folded = Folding::applyWhitespaceOnly( folded ); + //fixed = gd::toQString( folded ); - if( isHeadwordCorrect( fixed ) ) - headword = fixed; + //if( isHeadwordCorrect( fixed ) ) + // headword = fixed; + + headword = fixed; } void EpwingBook::getArticle( QString & headword, QString & articleText, diff --git a/folding.cc b/folding.cc index 6136b817..9cbeb136 100644 --- a/folding.cc +++ b/folding.cc @@ -596,7 +596,7 @@ bool isPunct( wchar ch ) case 0xFF64: // HALFWIDTH IDEOGRAPHIC COMMA return true; default: - return false; + return QChar::isPunct(ch)||QChar::isSymbol(ch); } } From 034e5e83788e550de32509a9cd14c8def458e710 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 5 Oct 2022 15:42:08 +0800 Subject: [PATCH 2/2] fix: headword dialog assert exception --- headwordsmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headwordsmodel.cpp b/headwordsmodel.cpp index 3d4d7f69..b486fb30 100644 --- a/headwordsmodel.cpp +++ b/headwordsmodel.cpp @@ -81,12 +81,12 @@ void HeadwordListModel::requestFinished() filtered << w; } } + if( filtered.isEmpty() ) + return; beginInsertRows( QModelIndex(), words.size(), words.size() + filtered.count() - 1 ); - for( const auto & word : filtered ) words.append( word ); - endInsertRows(); } }