diff options
author | Kenneth Heafield <github@kheafield.com> | 2013-04-25 22:42:30 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2013-04-25 22:42:30 +0400 |
commit | f1d366381033c0caae18f8d15305ded38734bdbf (patch) | |
tree | 22b0cbd3acc337a995701629bf9facbe179f5618 /moses/FeatureVector.h | |
parent | 8a1e944bb428a0af9f6c82c26e5633361ce4052c (diff) |
Back FactorCollection with a memory pool. Less memory for large vocabularies.
Diffstat (limited to 'moses/FeatureVector.h')
-rw-r--r-- | moses/FeatureVector.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/moses/FeatureVector.h b/moses/FeatureVector.h index 983248076..4401e3c03 100644 --- a/moses/FeatureVector.h +++ b/moses/FeatureVector.h @@ -45,6 +45,7 @@ #endif #include "util/check.hh" +#include "util/string_piece.hh" namespace Moses { @@ -68,9 +69,13 @@ namespace Moses { //A feature name can either be initialised as a pair of strings, //which will be concatenated with a SEP between them, or as //a single string, which will be used as-is. - explicit FName(const std::string root, const std::string name) - {init(root + SEP + name);} - explicit FName(const std::string& name) + FName(const StringPiece &root, const StringPiece &name) { + std::string assembled(root.data(), root.size()); + assembled += SEP; + assembled.append(name.data(), name.size()); + init(assembled); + } + explicit FName(const StringPiece &name) {init(name);} const std::string& name() const; @@ -89,7 +94,7 @@ namespace Moses { static void eraseId(size_t id); private: - void init(const std::string& name); + void init(const StringPiece& name); size_t m_id; #ifdef WITH_THREADS //reader-writer lock |