Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2013-05-19 18:22:50 +0400
committerKenneth Heafield <github@kheafield.com>2013-05-19 18:22:50 +0400
commit1c81c5582face5a984b3ede0e8b2672b78f9f4f0 (patch)
treeb62543158a188774fdb905892dee1f898cea2f4d /util
parent50652382e9285740de73654a7f47a8f4a9d993a1 (diff)
Make a slow code path for std::set FindStringPiece. I had fixed sparse features to use hash tables. But Hieu reverted this and kludged
FindStringPiece to be slow. This change returns my code to being fast and leaves the performance problem to Hieu/Eva.
Diffstat (limited to 'util')
-rw-r--r--util/string_piece_hash.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/string_piece_hash.hh b/util/string_piece_hash.hh
index c9502b1b5..31fdd5509 100644
--- a/util/string_piece_hash.hh
+++ b/util/string_piece_hash.hh
@@ -3,6 +3,8 @@
#include "util/string_piece.hh"
+#include <set>
+
#include <boost/functional/hash.hpp>
#include <boost/version.hpp>
@@ -42,4 +44,14 @@ template <class T> typename T::iterator FindStringPiece(T &t, const StringPiece
#endif
}
+// Horribly inefficient versions because Hieu undid my changes.
+template <class Entry, class Compare, class Alloc> typename std::set<Entry, Compare, Alloc>::const_iterator FindStringPiece(const std::set<Entry, Compare, Alloc> &t, const StringPiece &key) {
+ std::string temp(key.data(), key.size());
+ return t.find(temp);
+}
+template <class Entry, class Compare, class Alloc> typename std::set<Entry, Compare, Alloc>::iterator FindStringPiece(std::set<Entry, Compare, Alloc> &t, const StringPiece &key) {
+ std::string temp(key.data(), key.size());
+ return t.find(temp);
+}
+
#endif // UTIL_STRING_PIECE_HASH__