Skip to content

Commit b6db68f

Browse files
committed
Remove indirection in LanguageModelDawgInfo
1 parent 034d666 commit b6db68f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

wordrec/language_model.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ LanguageModelDawgInfo *LanguageModel::GenerateDawgInfo(
796796
dawg_args_->permuter = NO_PERM;
797797
} else {
798798
if (parent_vse->dawg_info == NULL) return NULL; // not a dict word path
799-
dawg_args_->active_dawgs = parent_vse->dawg_info->active_dawgs;
799+
dawg_args_->active_dawgs = &parent_vse->dawg_info->active_dawgs;
800800
dawg_args_->permuter = parent_vse->dawg_info->permuter;
801801
}
802802

@@ -822,8 +822,8 @@ LanguageModelDawgInfo *LanguageModel::GenerateDawgInfo(
822822
int i;
823823
// Check a that the path terminated before the current character is a word.
824824
bool has_word_ending = false;
825-
for (i = 0; i < parent_vse->dawg_info->active_dawgs->size(); ++i) {
826-
const DawgPosition &pos = (*parent_vse->dawg_info->active_dawgs)[i];
825+
for (i = 0; i < parent_vse->dawg_info->active_dawgs.size(); ++i) {
826+
const DawgPosition &pos = parent_vse->dawg_info->active_dawgs[i];
827827
const Dawg *pdawg = pos.dawg_index < 0
828828
? NULL : dict_->GetDawg(pos.dawg_index);
829829
if (pdawg == NULL || pos.back_to_punc) continue;;

wordrec/lm_state.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ typedef unsigned char LanguageModelFlagsType;
5959
/// component. It stores the set of active dawgs in which the sequence of
6060
/// letters on a path can be found.
6161
struct LanguageModelDawgInfo {
62-
LanguageModelDawgInfo(DawgPositionVector *a, PermuterType pt) : permuter(pt) {
63-
active_dawgs = new DawgPositionVector(*a);
64-
}
65-
~LanguageModelDawgInfo() {
66-
delete active_dawgs;
67-
}
68-
DawgPositionVector *active_dawgs;
62+
LanguageModelDawgInfo(const DawgPositionVector *a, PermuterType pt)
63+
: active_dawgs(*a), permuter(pt) {}
64+
DawgPositionVector active_dawgs;
6965
PermuterType permuter;
7066
};
7167

0 commit comments

Comments
 (0)