File tree Expand file tree Collapse file tree 3 files changed +3
-9
lines changed
Expand file tree Collapse file tree 3 files changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -526,7 +526,8 @@ void DocumentData::Shuffle() {
526526 TRand random;
527527 // Different documents get shuffled differently, but the same for the same
528528 // name.
529- random.set_seed (document_name_.c_str ());
529+ std::hash<std::string> hasher;
530+ random.set_seed (static_cast <uint64_t >(hasher (document_name_)));
530531 int num_pages = pages_.size ();
531532 // Execute one random swap for each page in the document.
532533 for (int i = 0 ; i < num_pages; ++i) {
Original file line number Diff line number Diff line change 2424#include < climits> // for INT_MIN, INT_MAX
2525#include < cmath> // std::isfinite
2626#include < cstdio>
27- #include < cstring>
2827#include < algorithm> // for std::find
29- #include < functional>
3028#include < string>
3129#include < vector>
3230
@@ -77,11 +75,6 @@ class TRand {
7775 void set_seed (uint64_t seed) {
7876 seed_ = seed;
7977 }
80- // Sets the seed using a hash of a string.
81- void set_seed (const std::string &str) {
82- std::hash<std::string> hasher;
83- set_seed (static_cast <uint64_t >(hasher (str)));
84- }
8578
8679 // Returns an integer in the range 0 to INT32_MAX.
8780 int32_t IntRand () {
Original file line number Diff line number Diff line change @@ -286,7 +286,7 @@ class TESS_API LSTMRecognizer {
286286protected:
287287 // Sets the random seed from the sample_iteration_;
288288 void SetRandomSeed () {
289- int64_t seed = static_cast < int64_t >( sample_iteration_) * 0x10000001 ;
289+ int64_t seed = sample_iteration_ * 0x10000001LL ;
290290 randomizer_.set_seed (seed);
291291 randomizer_.IntRand ();
292292 }
You can’t perform that action at this time.
0 commit comments