Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues reported by LGTM #2000

Merged
merged 6 commits into from
Oct 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ParamsTrainingHypothesis: Add copy assignment operator
This fixes a warning from LGTM:

    No matching copy assignment operator in class ParamsTrainingHypothesis.
    It is good practice to match a copy constructor
    with a copy assignment operator.

Use also a simpler expression for the size of features.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Oct 18, 2018
commit 7100a1463698da8090a7a27d0d4cd90109b72740
11 changes: 8 additions & 3 deletions src/ccstruct/params_training_featdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down