Skip to content

Commit 83588bc

Browse files
committed
Classify: Avoid unneeded new / delete operations
Both class variables BaselineCutoffs and CharNormCutoffs were pointers to fixed size arrays which were allocated in the constructor and deallocated in the destructor. These two extra allocations and two extra deallocations can be avoided. Signed-off-by: Stefan Weil <[email protected]>
1 parent bb75793 commit 83588bc

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

classify/classify.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,13 @@ Classify::Classify()
184184
learn_debug_win_ = NULL;
185185
learn_fragmented_word_debug_win_ = NULL;
186186
learn_fragments_debug_win_ = NULL;
187-
188-
CharNormCutoffs = new uinT16[MAX_NUM_CLASSES];
189-
BaselineCutoffs = new uinT16[MAX_NUM_CLASSES];
190187
}
191188

192189
Classify::~Classify() {
193190
EndAdaptiveClassifier();
194191
delete learn_debug_win_;
195192
delete learn_fragmented_word_debug_win_;
196193
delete learn_fragments_debug_win_;
197-
delete[] CharNormCutoffs;
198-
delete[] BaselineCutoffs;
199194
}
200195

201196

classify/classify.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ class Classify : public CCStruct {
529529
// value in the adaptive classifier. Both are indexed by unichar_id.
530530
// shapetable_cutoffs_ provides a similar value for each shape in the
531531
// shape_table_
532-
uinT16* CharNormCutoffs;
533-
uinT16* BaselineCutoffs;
532+
uinT16 CharNormCutoffs[MAX_NUM_CLASSES];
533+
uinT16 BaselineCutoffs[MAX_NUM_CLASSES];
534534
GenericVector<uinT16> shapetable_cutoffs_;
535535
ScrollView* learn_debug_win_;
536536
ScrollView* learn_fragmented_word_debug_win_;

0 commit comments

Comments
 (0)