build(deps): upgrade OpenCC to ver.1.4.0#1188
Open
frankslin wants to merge 1 commit into
Open
Conversation
See PR message for full analysis why this is safe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
librime 升級 OpenCC 至 ver.1.4.0
背景
librime 的
deps/opencc子模組原先指向 OpenCCver.1.1.9(commit556ed22),本次升級目標為ver.1.4.0(commit664674f)。OpenCC 相關改動見 https://github.com/byvoid/OpenCC/blob/master/NEWS.md 。
API 相容性分析
在執行升級前,針對
src/rime/gear/simplifier.cc中使用的所有 OpenCC 公開 API 進行逐一比對:opencc::Optional<T>/.IsNull()/.Get()Dict::Match()、Dict::MatchPrefix()DictEntry::KeyLength()、GetDefault()、Values()、NumValues()Converter::Convert(text)const std::string&改為std::string_view,std::string可隱式轉換,完全相容ConversionChain::GetConversions()Conversion::GetDict()UTF8Util::NextCharLength()、FromSubstr()opencc/opencc.h(cmake/FindOpencc.cmake用於探測安裝路徑)結論:
simplifier.cc無需任何修改即可與 OpenCC 1.4.0 相容。構建系統相容性分析
C++ 標準
OpenCC 1.4.0 將最低 C++ 標準從 C++14 提升至 C++17。librime 主
CMakeLists.txt已設置:無需修改。✓
deps.mk構建腳本cmake .在deps/opencc目錄下執行,OpenCC 為頂層專案,OPENCC_ENABLE_INSTALL自動預設為ON,install目標正常運作。ENABLE_DARTS選項在 1.4.0 中已移除,但deps.mk本來就未設置此選項,無影響。deps/marisa-0.3.1),與 librime 的deps/marisa-trie各自獨立,互不干擾。結論:
deps.mk無需任何修改。cmake/FindOpencc.cmakeopencc/opencc.h在 1.4.0 中仍然存在,函式庫名稱亦未改變。無需修改。✓ver.1.4.0 主要變更說明
與 librime 直接相關
GetConversionChain()返回nullptr的 bug(commitffddbe1c):在設置了 normalization 的 config 中,GetConversionChain()會返回nullptr,librime 對其解引用因而 crash。1.4.0 已修復,對穩定性有益。內部改動(API 層無感知)
Converter,而是透過Config::NewFromFile()取得具體實作,無影響。DictEntry新增string_view介面:KeyView()、GetDefaultView()等,減少字串複製,librime 未使用。新增功能(librime 暫未使用)
ConverterStream:串流轉換,適合分塊處理大段文字。ResourceProvider:自訂資源載入介面,可攔截詞典檔案的讀取來源。ConfigLoadOptions:可控制是否載入 tofu risk 詞典。PrefixMatchView:前綴比對快速路徑,返回string_view避免記憶體配置。執行結果
子模組指針變更
原始碼、CMake 設定、構建腳本均無任何修改。
構建與測試
rime_test 執行成功。