Skip to content

Commit

Permalink
Remove Converter argument from the Rewriter constructor.
Browse files Browse the repository at this point in the history
It is no longer used.

#codehealth

PiperOrigin-RevId: 712810236
  • Loading branch information
hiroyuki-komatsu committed Jan 7, 2025
1 parent 9e51d33 commit 5b7a333
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/converter/converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Converter::Converter(
general_noun_id_(pos_matcher_.GetGeneralNounId()) {
DCHECK(immutable_converter_);
predictor_ = predictor_factory(*modules_, this, immutable_converter_.get());
rewriter_ = rewriter_factory(*modules_, this);
rewriter_ = rewriter_factory(*modules_);
DCHECK(predictor_);
DCHECK(rewriter_);
}
Expand Down
2 changes: 1 addition & 1 deletion src/converter/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Converter final : public ConverterInterface {
const ImmutableConverterInterface *immutable_converter)>;

using RewriterFactory = std::function<std::unique_ptr<RewriterInterface>(
const engine::Modules &modules, const ConverterInterface *converter)>;
const engine::Modules &modules)>;

// Converter is initialized with the factory methods of ImmutableConverter,
// Predictor and Rewriter, so that all these sub components share the
Expand Down
10 changes: 4 additions & 6 deletions src/converter/converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ class ConverterTest : public testing::TestWithTempUserProfile {
return CreatePredictor(modules, predictor_type, converter,
immutable_converter);
},
[&](const engine::Modules &modules,
const ConverterInterface *converter) {
[&](const engine::Modules &modules) {
return std::move(rewriter);
});
}
Expand Down Expand Up @@ -1253,8 +1252,8 @@ TEST_F(ConverterTest, VariantExpansionForSuggestion) {
immutable_converter),
std::make_unique<UserHistoryPredictor>(modules, false), converter);
},
[](const engine::Modules &modules, const ConverterInterface *converter) {
return std::make_unique<Rewriter>(modules, *converter);
[](const engine::Modules &modules) {
return std::make_unique<Rewriter>(modules);
});

Segments segments;
Expand Down Expand Up @@ -1942,8 +1941,7 @@ TEST_F(ConverterTest, RevertConversion) {
const ImmutableConverterInterface *immutable_converter) {
return std::move(mock_predictor);
},
[&mock_rewriter](const engine::Modules &modules,
const ConverterInterface *converter) {
[&mock_rewriter](const engine::Modules &modules) {
return std::move(mock_rewriter);
});

Expand Down
5 changes: 2 additions & 3 deletions src/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ absl::Status Engine::Init(std::unique_ptr<engine::Modules> modules,
std::move(user_history_predictor), converter);
};

auto rewriter_factory = [](const engine::Modules &modules,
const ConverterInterface *converter) {
return std::make_unique<Rewriter>(modules, *converter);
auto rewriter_factory = [](const engine::Modules &modules) {
return std::make_unique<Rewriter>(modules);
};

auto converter = std::make_unique<Converter>(
Expand Down
4 changes: 1 addition & 3 deletions src/rewriter/rewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <memory>

#include "absl/flags/flag.h"
#include "converter/converter_interface.h"
#include "data_manager/data_manager.h"
#include "dictionary/dictionary_interface.h"
#include "dictionary/pos_group.h"
Expand Down Expand Up @@ -85,8 +84,7 @@ ABSL_FLAG(bool, use_history_rewriter, true, "Use history rewriter or not.");

namespace mozc {

Rewriter::Rewriter(const engine::Modules &modules,
const ConverterInterface &parent_converter) {
Rewriter::Rewriter(const engine::Modules &modules) {
const DataManager *data_manager = &modules.GetDataManager();
const dictionary::DictionaryInterface *dictionary = modules.GetDictionary();
const dictionary::PosMatcher &pos_matcher = *modules.GetPosMatcher();
Expand Down
4 changes: 1 addition & 3 deletions src/rewriter/rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@
#ifndef MOZC_REWRITER_REWRITER_H_
#define MOZC_REWRITER_REWRITER_H_

#include "converter/converter_interface.h"
#include "engine/modules.h"
#include "rewriter/merger_rewriter.h"

namespace mozc {

class Rewriter : public MergerRewriter {
public:
Rewriter(const engine::Modules &modules,
const ConverterInterface &parent_converter);
explicit Rewriter(const engine::Modules &modules);
Rewriter(const Rewriter &) = delete;
Rewriter &operator=(const Rewriter &) = delete;
};
Expand Down
4 changes: 1 addition & 3 deletions src/rewriter/rewriter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <string>

#include "absl/log/check.h"
#include "converter/converter_mock.h"
#include "converter/segments.h"
#include "data_manager/testing/mock_data_manager.h"
#include "engine/modules.h"
Expand Down Expand Up @@ -64,13 +63,12 @@ class RewriterTest : public testing::TestWithTempUserProfile {
void SetUp() override {
modules_ = std::make_unique<engine::Modules>();
CHECK_OK(modules_->Init(std::make_unique<testing::MockDataManager>()));
rewriter_ = std::make_unique<Rewriter>(*modules_, mock_converter_);
rewriter_ = std::make_unique<Rewriter>(*modules_);
}

const RewriterInterface *GetRewriter() const { return rewriter_.get(); }

std::unique_ptr<engine::Modules> modules_;
MockConverter mock_converter_;
std::unique_ptr<Rewriter> rewriter_;
};

Expand Down

0 comments on commit 5b7a333

Please sign in to comment.