Merge pull request #2000 from stweil/lgtm

Fix some issues reported by LGTM
This commit is contained in:
zdenop 2018-10-18 19:15:00 +02:00 committed by GitHub
commit ac2fc208bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 3 deletions

View File

@ -79,6 +79,13 @@ struct LineHypothesis {
LineHypothesis(const LineHypothesis &other)
: ty(other.ty), model(other.model) {}
// Copy assignment operator.
LineHypothesis& operator=(const LineHypothesis& other) {
ty = other.ty;
model = other.model;
return *this;
}
bool operator==(const LineHypothesis &other) const {
return ty == other.ty && model == other.model;
}

View File

@ -289,6 +289,8 @@ struct BlamerBundle {
void SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debug);
private:
// Copy assignment operator (currently unused, therefore private).
BlamerBundle& operator=(const BlamerBundle& other);
void SetBlame(IncorrectResultReason irr, const STRING &msg,
const WERD_CHOICE *choice, bool debug) {
incorrect_result_reason_ = irr;

View File

@ -144,6 +144,9 @@ class ROW:public ELIST_LINK
ROW& operator= (const ROW & source);
private:
// Copy constructor (currently unused, therefore private).
ROW(const ROW& source);
int32_t kerning; //inter char gap
int32_t spacing; //inter word gap
TBOX bound_box; //bounding box

View File

@ -105,14 +105,19 @@ int ParamsTrainingFeatureByName(const char *name);
// Entry with features extracted from a single OCR hypothesis for a word.
struct ParamsTrainingHypothesis {
ParamsTrainingHypothesis() : cost(0.0) {
memset(features, 0, sizeof(float) * PTRAIN_NUM_FEATURE_TYPES);
memset(features, 0, sizeof(features));
}
ParamsTrainingHypothesis(const ParamsTrainingHypothesis &other) {
memcpy(features, other.features,
sizeof(float) * PTRAIN_NUM_FEATURE_TYPES);
memcpy(features, other.features, sizeof(features));
str = other.str;
cost = other.cost;
}
ParamsTrainingHypothesis& operator=(const ParamsTrainingHypothesis& other) {
memcpy(features, other.features, sizeof(features));
str = other.str;
cost = other.cost;
return *this;
}
float features[PTRAIN_NUM_FEATURE_TYPES];
STRING str; // string corresponding to word hypothesis (for debugging)
float cost; // path cost computed by segsearch

View File

@ -129,6 +129,24 @@ BLOB_CHOICE::BLOB_CHOICE(const BLOB_CHOICE &other) : ELIST_LINK(other) {
fonts_ = other.fonts_;
}
// Copy assignment operator.
BLOB_CHOICE& BLOB_CHOICE::operator=(const BLOB_CHOICE& other) {
ELIST_LINK::operator=(other);
unichar_id_ = other.unichar_id();
rating_ = other.rating();
certainty_ = other.certainty();
fontinfo_id_ = other.fontinfo_id();
fontinfo_id2_ = other.fontinfo_id2();
script_id_ = other.script_id();
matrix_cell_ = other.matrix_cell_;
min_xheight_ = other.min_xheight_;
max_xheight_ = other.max_xheight_;
yshift_ = other.yshift();
classifier_ = other.classifier_;
fonts_ = other.fonts_;
return *this;
}
// Returns true if *this and other agree on the baseline and x-height
// to within some tolerance based on a given estimate of the x-height.
bool BLOB_CHOICE::PosAndSizeAgree(const BLOB_CHOICE& other, float x_height,

View File

@ -197,6 +197,9 @@ class BLOB_CHOICE: public ELIST_LINK
}
private:
// Copy assignment operator.
BLOB_CHOICE& operator=(const BLOB_CHOICE& other);
UNICHAR_ID unichar_id_; // unichar id
// Fonts and scores. Allowed to be empty.
GenericVector<tesseract::ScoredFont> fonts_;

View File

@ -52,6 +52,8 @@ class C_OUTLINE_FRAG:public ELIST_LINK
int16_t ycoord; //coord of cut pt
private:
// Copy constructor (currently unused, therefore private).
C_OUTLINE_FRAG(const C_OUTLINE_FRAG& other);
};
ELISTIZEH(C_OUTLINE_FRAG)