diff --git a/src/ccstruct/imagedata.cpp b/src/ccstruct/imagedata.cpp index 03c5049c42..e45a5dedb2 100644 --- a/src/ccstruct/imagedata.cpp +++ b/src/ccstruct/imagedata.cpp @@ -526,7 +526,8 @@ void DocumentData::Shuffle() { TRand random; // Different documents get shuffled differently, but the same for the same // name. - random.set_seed(document_name_.c_str()); + std::hash hasher; + random.set_seed(static_cast(hasher(document_name_))); int num_pages = pages_.size(); // Execute one random swap for each page in the document. for (int i = 0; i < num_pages; ++i) { diff --git a/src/ccutil/helpers.h b/src/ccutil/helpers.h index 6bfcf207f4..fa2f38ec83 100644 --- a/src/ccutil/helpers.h +++ b/src/ccutil/helpers.h @@ -24,9 +24,7 @@ #include // for INT_MIN, INT_MAX #include // std::isfinite #include -#include #include // for std::find -#include #include #include @@ -77,11 +75,6 @@ class TRand { void set_seed(uint64_t seed) { seed_ = seed; } - // Sets the seed using a hash of a string. - void set_seed(const std::string &str) { - std::hash hasher; - set_seed(static_cast(hasher(str))); - } // Returns an integer in the range 0 to INT32_MAX. int32_t IntRand() { diff --git a/src/lstm/lstmrecognizer.h b/src/lstm/lstmrecognizer.h index bfefac8f1b..4234cf324e 100644 --- a/src/lstm/lstmrecognizer.h +++ b/src/lstm/lstmrecognizer.h @@ -286,7 +286,7 @@ class TESS_API LSTMRecognizer { protected: // Sets the random seed from the sample_iteration_; void SetRandomSeed() { - int64_t seed = static_cast(sample_iteration_) * 0x10000001; + int64_t seed = sample_iteration_ * 0x10000001LL; randomizer_.set_seed(seed); randomizer_.IntRand(); }