mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Simplify and clean code related to class TRand
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
Some checks failed
CodeQL / Analyze (cpp) (push) Has been cancelled
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
9f17a3fdd0
commit
c1bb752ed5
@ -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<std::string> hasher;
|
||||
random.set_seed(static_cast<uint64_t>(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) {
|
||||
|
@ -24,9 +24,7 @@
|
||||
#include <climits> // for INT_MIN, INT_MAX
|
||||
#include <cmath> // std::isfinite
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <algorithm> // for std::find
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -77,11 +75,6 @@ public:
|
||||
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<std::string> hasher;
|
||||
set_seed(static_cast<uint64_t>(hasher(str)));
|
||||
}
|
||||
|
||||
// Returns an integer in the range 0 to INT32_MAX.
|
||||
int32_t IntRand() {
|
||||
|
@ -286,7 +286,7 @@ public:
|
||||
protected:
|
||||
// Sets the random seed from the sample_iteration_;
|
||||
void SetRandomSeed() {
|
||||
int64_t seed = static_cast<int64_t>(sample_iteration_) * 0x10000001;
|
||||
int64_t seed = sample_iteration_ * 0x10000001LL;
|
||||
randomizer_.set_seed(seed);
|
||||
randomizer_.IntRand();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user