Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Jan 9, 2025
2 parents 7dd603c + c4cbd4c commit 428a503
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 95 deletions.
5 changes: 2 additions & 3 deletions src/converter/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
namespace mozc {
namespace {

using ::mozc::prediction::PredictorInterface;
using ::mozc::usage_stats::UsageStats;

constexpr size_t kErrorIndex = static_cast<size_t>(-1);
Expand Down Expand Up @@ -240,8 +239,8 @@ bool Converter::StartPrediction(const ConversionRequest &request,
if (ShouldSetKeyForPrediction(key, *segments)) {
SetKey(segments, key);
}
DCHECK_EQ(1, segments->conversion_segments_size());
DCHECK_EQ(key, segments->conversion_segment(0).key());
DCHECK_EQ(segments->conversion_segments_size(), 1);
DCHECK_EQ(segments->conversion_segment(0).key(), key);

if (!predictor_->PredictForRequest(request, segments)) {
// Prediction can fail for keys like "12". Even in such cases, rewriters
Expand Down
11 changes: 0 additions & 11 deletions src/engine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,6 @@ mozc_cc_library(
),
)

mozc_cc_test(
name = "engine_factory_test",
srcs = ["engine_factory_test.cc"],
deps = [
":engine_factory",
":engine_interface",
"//testing:gunit_main",
"@com_google_absl//absl/strings:string_view",
],
)

mozc_cc_library(
name = "eval_engine_factory",
srcs = ["eval_engine_factory.cc"],
Expand Down
6 changes: 0 additions & 6 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ class Engine : public EngineInterface {
return converter_ ? converter_.get() : minimal_converter_.get();
}

absl::string_view GetPredictorName() const override {
static absl::string_view kDefaultPredictorName = "MinimalPredictor";
return converter_ ? converter_->predictor()->GetPredictorName()
: kDefaultPredictorName;
}

// Functions for Reload, Sync, Wait return true if successfully operated
// or did nothing.
bool Reload() override;
Expand Down
50 changes: 0 additions & 50 deletions src/engine/engine_factory_test.cc

This file was deleted.

3 changes: 0 additions & 3 deletions src/engine/engine_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class EngineInterface {
// engine class and should not be deleted by callers.
virtual ConverterInterface *GetConverter() const = 0;

// Returns the predictor name.
virtual absl::string_view GetPredictorName() const = 0;

// Gets the version of underlying data set.
virtual absl::string_view GetDataVersion() const = 0;

Expand Down
1 change: 0 additions & 1 deletion src/engine/engine_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace mozc {
class MockEngine : public EngineInterface {
public:
MOCK_METHOD(ConverterInterface *, GetConverter, (), (const, override));
MOCK_METHOD(absl::string_view, GetPredictorName, (), (const, override));
MOCK_METHOD(absl::string_view, GetDataVersion, (), (const, override));
MOCK_METHOD(bool, Reload, (), (override));
MOCK_METHOD(bool, Sync, (), (override));
Expand Down
23 changes: 4 additions & 19 deletions src/session/session_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ using ::mozc::commands::Request;
using ::mozc::config::Config;
using ::mozc::usage_stats::UsageStats;

constexpr size_t kDefaultMaxHistorySize = 3;

absl::string_view GetCandidateShortcuts(
config::Config::SelectionShortcut selection_shortcut) {
// Keyboard shortcut for candidates.
Expand All @@ -95,15 +93,6 @@ absl::string_view GetCandidateShortcuts(
return shortcut;
}

// Creates ConversionRequest to fill incognito candidate words.
ConversionRequest CreateIncognitoConversionRequest(
const ConversionRequest &base_request, const Config &incognito_config) {
return ConversionRequestBuilder()
.SetConversionRequest(base_request)
.SetConfig(incognito_config)
.Build();
}

// Calculate cursor offset for committed text.
int32_t CalculateCursorOffset(absl::string_view committed_text) {
// If committed_text is a bracket pair, set the cursor in the middle.
Expand Down Expand Up @@ -795,8 +784,8 @@ void SessionConverter::CommitSegmentsInternal(
candidate_list_visible_ = false;
*consumed_key_size = 0;

// If the number of segments is one, just call Commit.
if (segments_.conversion_segments_size() == segments_to_commit) {
// If commit all segments, just call Commit.
if (segments_.conversion_segments_size() <= segments_to_commit) {
Commit(composer, context);
return;
}
Expand All @@ -813,15 +802,11 @@ void SessionConverter::CommitSegmentsInternal(
std::vector<size_t> candidate_ids;
for (size_t i = 0; i < segments_to_commit; ++i) {
// Get the i-th (0 origin) conversion segment and the selected candidate.
Segment *segment = segments_.mutable_conversion_segment(i);
if (!segment) {
LOG(ERROR) << "There is no segment on position " << i;
return;
}
const Segment &segment = segments_.conversion_segment(i);

// Accumulate the size of i-th segment's key.
// The caller will remove corresponding characters from the composer.
*consumed_key_size += Util::CharsLen(segment->key());
*consumed_key_size += Util::CharsLen(segment.key());

// Collect candidate's id for each segment.
candidate_ids.push_back(GetCandidateIndexForConverter(i));
Expand Down
3 changes: 1 addition & 2 deletions src/session/session_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,15 +803,14 @@ TEST_F(SessionHandlerTest, ReloadFromMinimalEngine) {
CHECK_OK(modules->Init(std::move(data_manager)));

SessionHandler handler(std::move(engine));
EXPECT_EQ(handler.engine().GetPredictorName(), "MinimalPredictor");
EXPECT_NE(handler.GetDataVersion(), mock_version_);

ASSERT_EQ(SendMockEngineReloadRequest(handler, mock_request_),
EngineReloadResponse::ACCEPTED);

// CreateSession updates the Engine including the Predictor.
uint64_t id = 0;
ASSERT_TRUE(CreateSession(handler, &id));
EXPECT_EQ(handler.engine().GetPredictorName(), "MobilePredictor");
EXPECT_EQ(handler.GetDataVersion(), mock_version_);
}

Expand Down

0 comments on commit 428a503

Please sign in to comment.