@@ -799,8 +799,7 @@ void WERD_RES::ReplaceBestChoice(WERD_CHOICE* choice) {
799
799
// the best_choice->state.
800
800
void WERD_RES::RebuildBestState () {
801
801
ASSERT_HOST (best_choice != nullptr );
802
- if (rebuild_word != nullptr )
803
- delete rebuild_word;
802
+ delete rebuild_word;
804
803
rebuild_word = new TWERD;
805
804
if (seam_array.empty ())
806
805
start_seam_list (chopped_word, &seam_array);
@@ -826,8 +825,7 @@ void WERD_RES::RebuildBestState() {
826
825
// Copies the chopped_word to the rebuild_word, faking a best_state as well.
827
826
// Also sets up the output box_word.
828
827
void WERD_RES::CloneChoppedToRebuild () {
829
- if (rebuild_word != nullptr )
830
- delete rebuild_word;
828
+ delete rebuild_word;
831
829
rebuild_word = new TWERD (*chopped_word);
832
830
SetupBoxWord ();
833
831
int word_len = box_word->length ();
@@ -841,8 +839,7 @@ void WERD_RES::CloneChoppedToRebuild() {
841
839
842
840
// Sets/replaces the box_word with one made from the rebuild_word.
843
841
void WERD_RES::SetupBoxWord () {
844
- if (box_word != nullptr )
845
- delete box_word;
842
+ delete box_word;
846
843
rebuild_word->ComputeBoundingBoxes ();
847
844
box_word = tesseract::BoxWord::CopyFromNormalized (rebuild_word);
848
845
box_word->ClipToOriginalWord (denorm.block (), word);
@@ -1130,7 +1127,7 @@ void WERD_RES::InitPointers() {
1130
1127
}
1131
1128
1132
1129
void WERD_RES::Clear () {
1133
- if (word != nullptr && combination) {
1130
+ if (combination) {
1134
1131
delete word;
1135
1132
}
1136
1133
word = nullptr ;
@@ -1145,23 +1142,15 @@ void WERD_RES::ClearResults() {
1145
1142
fontinfo2 = nullptr ;
1146
1143
fontinfo_id_count = 0 ;
1147
1144
fontinfo_id2_count = 0 ;
1148
- if (bln_boxes != nullptr ) {
1149
- delete bln_boxes;
1150
- bln_boxes = nullptr ;
1151
- }
1145
+ delete bln_boxes;
1146
+ bln_boxes = nullptr ;
1152
1147
blob_row = nullptr ;
1153
- if (chopped_word != nullptr ) {
1154
- delete chopped_word;
1155
- chopped_word = nullptr ;
1156
- }
1157
- if (rebuild_word != nullptr ) {
1158
- delete rebuild_word;
1159
- rebuild_word = nullptr ;
1160
- }
1161
- if (box_word != nullptr ) {
1162
- delete box_word;
1163
- box_word = nullptr ;
1164
- }
1148
+ delete chopped_word;
1149
+ chopped_word = nullptr ;
1150
+ delete rebuild_word;
1151
+ rebuild_word = nullptr ;
1152
+ delete box_word;
1153
+ box_word = nullptr ;
1165
1154
best_state.clear ();
1166
1155
correct_text.clear ();
1167
1156
seam_array.delete_data_pointers ();
@@ -1174,15 +1163,11 @@ void WERD_RES::ClearResults() {
1174
1163
}
1175
1164
void WERD_RES::ClearWordChoices () {
1176
1165
best_choice = nullptr ;
1177
- if (raw_choice != nullptr ) {
1178
- delete raw_choice;
1179
- raw_choice = nullptr ;
1180
- }
1166
+ delete raw_choice;
1167
+ raw_choice = nullptr ;
1181
1168
best_choices.clear ();
1182
- if (ep_choice != nullptr ) {
1183
- delete ep_choice;
1184
- ep_choice = nullptr ;
1185
- }
1169
+ delete ep_choice;
1170
+ ep_choice = nullptr ;
1186
1171
}
1187
1172
void WERD_RES::ClearRatings () {
1188
1173
if (ratings != nullptr ) {
0 commit comments