Skip to content

Commit

Permalink
Move initial values for class ColPartition from constructor to header…
Browse files Browse the repository at this point in the history
… file

This fixes compiler warnings caused by
commit 5b4565b:

    src/textord/colpartition.cpp:91:24: warning: field 'last_column_'
      will be initialized after field 'column_set_' [-Wreorder]
    src/textord/colpartition.cpp:93:37: warning: field 'inside_table_column_'
      will be initialized after field 'nearest_neighbor_above_' [-Wreorder]
    src/textord/colpartition.cpp:95:58: warning: field 'space_to_right_'
      will be initialized after field 'owns_blobs_' [-Wreorder]

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Sep 16, 2019
1 parent 8f66020 commit 081521f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 45 deletions.
18 changes: 4 additions & 14 deletions src/textord/colpartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,10 @@ const int kMaxColorDistance = 900;
// Vertical is the direction of logical vertical on the possibly skewed image.
ColPartition::ColPartition(BlobRegionType blob_type, const ICOORD& vertical)
: left_margin_(-INT32_MAX), right_margin_(INT32_MAX),
median_bottom_(INT32_MAX), median_top_(-INT32_MAX), median_height_(0),
median_left_(INT32_MAX), median_right_(-INT32_MAX), median_width_(0),
blob_type_(blob_type), flow_(BTFT_NONE), good_blob_score_(0),
good_width_(false), good_column_(false),
left_key_tab_(false), right_key_tab_(false),
left_key_(0), right_key_(0), type_(PT_UNKNOWN), vertical_(vertical),
working_set_(nullptr), last_add_was_vertical_(false), block_owned_(false),
desperately_merged_(false),
first_column_(-1), last_column_(-1), column_set_(nullptr),
side_step_(0), top_spacing_(0), bottom_spacing_(0),
type_before_table_(PT_UNKNOWN), inside_table_column_(false),
nearest_neighbor_above_(nullptr), nearest_neighbor_below_(nullptr),
space_above_(0), space_below_(0), space_to_left_(0), space_to_right_(0),
owns_blobs_(true) {
median_bottom_(INT32_MAX), median_top_(-INT32_MAX),
median_left_(INT32_MAX), median_right_(-INT32_MAX),
blob_type_(blob_type),
vertical_(vertical) {
memset(special_blobs_densities_, 0, sizeof(special_blobs_densities_));
}

Expand Down
62 changes: 31 additions & 31 deletions src/textord/colpartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,35 +844,35 @@ class ColPartition : public ELIST2_LINK {
int median_bottom_;
int median_top_;
// Median height of blobs in this partition.
int median_height_;
int median_height_ = 0;
// Median left and right of blobs in this partition.
int median_left_;
int median_right_;
// Median width of blobs in this partition.
int median_width_;
int median_width_ = 0;
// blob_region_type_ for the blobs in this partition.
BlobRegionType blob_type_;
BlobTextFlowType flow_; // Quality of text flow.
BlobTextFlowType flow_ = BTFT_NONE; // Quality of text flow.
// Total of GoodTextBlob results for all blobs in the partition.
int good_blob_score_;
int good_blob_score_ = 0;
// True if this partition has a common width.
bool good_width_;
bool good_width_ = false;
// True if this is a good column candidate.
bool good_column_;
bool good_column_ = false;
// True if the left_key_ is from a tab vector.
bool left_key_tab_;
bool left_key_tab_ = false;
// True if the right_key_ is from a tab vector.
bool right_key_tab_;
bool right_key_tab_ = false;
// Left and right sort keys for the edges of the partition.
// If the respective *_key_tab_ is true then this key came from a tab vector.
// If not, then the class promises to keep the key equal to the sort key
// for the respective edge of the bounding box at the MidY, so that
// LeftAtY and RightAtY always returns an x coordinate on the line parallel
// to vertical_ through the bounding box edge at MidY.
int left_key_;
int right_key_;
int left_key_ = 0;
int right_key_ = 0;
// Type of this partition after looking at its relation to the columns.
PolyBlockType type_;
PolyBlockType type_ = PT_UNKNOWN;
// The global vertical skew direction.
ICOORD vertical_;
// All boxes in the partition stored in increasing left edge coordinate.
Expand All @@ -882,40 +882,40 @@ class ColPartition : public ELIST2_LINK {
// The partitions below that matched this.
ColPartition_CLIST lower_partners_;
// The WorkingPartSet it lives in while blocks are being made.
WorkingPartSet* working_set_;
WorkingPartSet* working_set_ = nullptr;
// Column_set_ is the column layout applicable to this ColPartition.
ColPartitionSet* column_set_;
ColPartitionSet* column_set_ = nullptr;
// Flag is true when AddBox is sorting vertically, false otherwise.
bool last_add_was_vertical_;
bool last_add_was_vertical_ = false;
// True when the partition's ownership has been taken from the grid and
// placed in a working set, or, after that, in the good_parts_ list.
bool block_owned_;
bool block_owned_ = false;
// Flag to indicate that this partition was subjected to a desperate merge,
// and therefore the textlines need rebuilding.
bool desperately_merged_;
bool owns_blobs_; // Does the partition own its blobs?
bool desperately_merged_ = false;
bool owns_blobs_ = true; // Does the partition own its blobs?
// The first and last column that this partition applies to.
// Flowing partitions (see type_) will have an equal first and last value
// of the form 2n + 1, where n is the zero-based index into the partitions
// in column_set_. (See ColPartitionSet::GetColumnByIndex).
// Heading partitions will have unequal values of the same form.
// Pullout partitions will have equal values, but may have even values,
// indicating placement between columns.
int first_column_;
int last_column_;
int first_column_ = -1;
int last_column_ = -1;
// Linespacing data.
int side_step_; // Median y-shift to next blob on same line.
int top_spacing_; // Line spacing from median_top_.
int bottom_spacing_; // Line spacing from median_bottom_.
int side_step_ = 0; // Median y-shift to next blob on same line.
int top_spacing_ = 0; // Line spacing from median_top_.
int bottom_spacing_ = 0; // Line spacing from median_bottom_.

// Nearest neighbor above with major x-overlap
ColPartition* nearest_neighbor_above_;
ColPartition* nearest_neighbor_above_ = nullptr;
// Nearest neighbor below with major x-overlap
ColPartition* nearest_neighbor_below_;
int space_above_; // Distance from nearest_neighbor_above
int space_below_; // Distance from nearest_neighbor_below
int space_to_left_; // Distance from the left edge of the column
int space_to_right_; // Distance from the right edge of the column
ColPartition* nearest_neighbor_below_ = nullptr;
int space_above_ = 0; // Distance from nearest_neighbor_above
int space_below_ = 0; // Distance from nearest_neighbor_below
int space_to_left_ = 0; // Distance from the left edge of the column
int space_to_right_ = 0; // Distance from the right edge of the column
// Color foreground/background data.
uint8_t color1_[kRGBRMSColors];
uint8_t color2_[kRGBRMSColors];
Expand All @@ -924,9 +924,9 @@ class ColPartition : public ELIST2_LINK {
// Type of this partition before considering it as a table cell. This is
// used to revert the type if a partition is first marked as a table cell but
// later filtering steps decide it does not belong to a table
PolyBlockType type_before_table_;
bool inside_table_column_; // Check whether the current partition has been
// assigned to a table column
PolyBlockType type_before_table_ = PT_UNKNOWN;
// Check whether the current partition has been assigned to a table column.
bool inside_table_column_ = false;
};

// Typedef it now in case it becomes a class later.
Expand Down

0 comments on commit 081521f

Please sign in to comment.