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.
This commit is contained in:
Kenneth Heafield 2013-05-19 10:22:50 -04:00
parent 50652382e9
commit 1c81c5582f

View File

@ -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__