Remove NodeAllocatorInterface
NodeAllocatorInterface is no longer necessary thanks to r547 (so far it was used in DictionaryInterface but it no longer exists).
This is just an internal clean-up. No user-visible behavior change is intended.
BUG=none
TEST=unittest
git-svn-id: https://mozc.googlecode.com/svn/trunk@548 a6090854-d499-a067-5803-1114d4e51264
diff --git a/src/converter/immutable_converter.cc b/src/converter/immutable_converter.cc
index 7e39b59..ba2ff38 100644
--- a/src/converter/immutable_converter.cc
+++ b/src/converter/immutable_converter.cc
@@ -50,6 +50,7 @@
#include "converter/lattice.h"
#include "converter/nbest_generator.h"
#include "converter/node.h"
+#include "converter/node_allocator.h"
#include "converter/node_list_builder.h"
#include "converter/segmenter_interface.h"
#include "converter/segments.h"
@@ -80,7 +81,7 @@
KeyCorrectedNodeListBuilder(size_t pos,
StringPiece original_lookup_key,
const KeyCorrector *key_corrector,
- NodeAllocatorInterface *allocator)
+ NodeAllocator *allocator)
: BaseNodeListBuilder(allocator, allocator->max_nodes_size()),
pos_(pos),
original_lookup_key_(original_lookup_key),
@@ -739,7 +740,7 @@
class NodeListBuilderWithCacheEnabled : public NodeListBuilderForLookupPrefix {
public:
- NodeListBuilderWithCacheEnabled(NodeAllocatorInterface *allocator,
+ NodeListBuilderWithCacheEnabled(NodeAllocator *allocator,
size_t min_key_length)
: NodeListBuilderForLookupPrefix(allocator,
allocator->max_nodes_size(),
@@ -1187,7 +1188,7 @@
// Adds penalty for predictive nodes when building a node list.
class NodeListBuilderForPredictiveNodes : public BaseNodeListBuilder {
public:
- NodeListBuilderForPredictiveNodes(NodeAllocatorInterface *allocator,
+ NodeListBuilderForPredictiveNodes(NodeAllocator *allocator,
int limit, const POSMatcher *pos_matcher)
: BaseNodeListBuilder(allocator, limit), pos_matcher_(pos_matcher) {}
diff --git a/src/converter/lattice.cc b/src/converter/lattice.cc
index 6e48454..add7f7c 100644
--- a/src/converter/lattice.cc
+++ b/src/converter/lattice.cc
@@ -149,7 +149,7 @@
Lattice::~Lattice() {}
-NodeAllocatorInterface *Lattice::node_allocator() const {
+NodeAllocator *Lattice::node_allocator() const {
return node_allocator_.get();
}
diff --git a/src/converter/lattice.h b/src/converter/lattice.h
index a84d91c..31b5f5d 100644
--- a/src/converter/lattice.h
+++ b/src/converter/lattice.h
@@ -36,19 +36,17 @@
#include "base/port.h"
#include "base/scoped_ptr.h"
#include "base/string_piece.h"
+#include "converter/node.h"
+#include "converter/node_allocator.h"
namespace mozc {
-struct Node;
-class NodeAllocator;
-class NodeAllocatorInterface;
-
class Lattice {
public:
Lattice();
~Lattice();
- NodeAllocatorInterface *node_allocator() const;
+ NodeAllocator *node_allocator() const;
// set key and initalizes lattice with key.
void SetKey(StringPiece key);
diff --git a/src/converter/node.h b/src/converter/node.h
index c3221aa..b5640f5 100644
--- a/src/converter/node.h
+++ b/src/converter/node.h
@@ -234,25 +234,6 @@
}
};
-class NodeAllocatorInterface {
- public:
- NodeAllocatorInterface() : max_nodes_size_(8192) {}
- virtual ~NodeAllocatorInterface() {}
-
- virtual Node *NewNode() = 0;
-
- virtual size_t max_nodes_size() const {
- return max_nodes_size_;
- }
-
- virtual void set_max_nodes_size(size_t max_nodes_size) {
- max_nodes_size_ = max_nodes_size;
- }
-
- private:
- size_t max_nodes_size_;
-};
-
} // namespace mozc
#endif // MOZC_CONVERTER_NODE_H_
diff --git a/src/converter/node_allocator.h b/src/converter/node_allocator.h
index 7a69236..eaf3fd3 100644
--- a/src/converter/node_allocator.h
+++ b/src/converter/node_allocator.h
@@ -30,19 +30,20 @@
#ifndef MOZC_CONVERTER_NODE_ALLOCATOR_H_
#define MOZC_CONVERTER_NODE_ALLOCATOR_H_
-#include "base/port.h"
#include "base/freelist.h"
#include "base/logging.h"
+#include "base/port.h"
#include "converter/node.h"
namespace mozc {
-class NodeAllocator : public NodeAllocatorInterface {
+class NodeAllocator {
public:
- NodeAllocator() : node_freelist_(1024), node_count_(0) {}
- virtual ~NodeAllocator() {}
+ NodeAllocator() : node_freelist_(1024), max_nodes_size_(8192),
+ node_count_(0) {}
+ ~NodeAllocator() {}
- virtual Node *NewNode() {
+ Node *NewNode() {
Node *node = node_freelist_.Alloc();
DCHECK(node);
node->Init();
@@ -50,18 +51,27 @@
return node;
}
- // Free all nodes allocateed by NewNode()
+ // Frees all nodes allocateed by NewNode().
void Free() {
node_freelist_.Free();
node_count_ = 0;
}
+ size_t max_nodes_size() const {
+ return max_nodes_size_;
+ }
+
+ void set_max_nodes_size(size_t max_nodes_size) {
+ max_nodes_size_ = max_nodes_size;
+ }
+
size_t node_count() const {
return node_count_;
}
private:
FreeList<Node> node_freelist_;
+ size_t max_nodes_size_;
size_t node_count_;
DISALLOW_COPY_AND_ASSIGN(NodeAllocator);
diff --git a/src/converter/node_list_builder.h b/src/converter/node_list_builder.h
index 4c7a359..601adb9 100644
--- a/src/converter/node_list_builder.h
+++ b/src/converter/node_list_builder.h
@@ -30,8 +30,8 @@
#ifndef MOZC_CONVERTER_NODE_LIST_BUILDER_H_
#define MOZC_CONVERTER_NODE_LIST_BUILDER_H_
-#include "base/port.h"
#include "base/logging.h"
+#include "base/port.h"
#include "base/trie.h"
#include "converter/node.h"
#include "dictionary/dictionary_interface.h"
@@ -47,7 +47,7 @@
// dictionary lookup.
class BaseNodeListBuilder : public DictionaryInterface::Callback {
public:
- BaseNodeListBuilder(NodeAllocatorInterface *allocator, int limit)
+ BaseNodeListBuilder(NodeAllocator *allocator, int limit)
: allocator_(allocator), limit_(limit), penalty_(0), result_(NULL) {
DCHECK(allocator_) << "Allocator must not be NULL";
}
@@ -71,7 +71,7 @@
int limit() const { return limit_; }
int penalty() const { return penalty_; }
Node *result() const { return result_; }
- NodeAllocatorInterface *allocator() { return allocator_; }
+ NodeAllocator *allocator() { return allocator_; }
Node *NewNodeFromToken(const Token &token) {
Node *new_node = allocator_->NewNode();
@@ -87,7 +87,7 @@
}
protected:
- NodeAllocatorInterface *allocator_;
+ NodeAllocator *allocator_;
int limit_;
int penalty_;
Node *result_;
@@ -100,7 +100,7 @@
// This class is also defined inline.
class NodeListBuilderForLookupPrefix : public BaseNodeListBuilder {
public:
- NodeListBuilderForLookupPrefix(NodeAllocatorInterface *allocator,
+ NodeListBuilderForLookupPrefix(NodeAllocator *allocator,
int limit, size_t min_key_length)
: BaseNodeListBuilder(allocator, limit),
min_key_length_(min_key_length) {}
diff --git a/src/dictionary/dictionary_mock.h b/src/dictionary/dictionary_mock.h
index af30841..5899eae 100644
--- a/src/dictionary/dictionary_mock.h
+++ b/src/dictionary/dictionary_mock.h
@@ -63,9 +63,6 @@
namespace mozc {
-// These structures are defined in converter
-class NodeAllocatorInterface;
-
class DictionaryMock : public DictionaryInterface {
public:
DictionaryMock();
diff --git a/src/mozc_version_template.txt b/src/mozc_version_template.txt
index 573db73..30a183c 100644
--- a/src/mozc_version_template.txt
+++ b/src/mozc_version_template.txt
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=16
-BUILD=2064
+BUILD=2065
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.