Skip to content

Commit

Permalink
Remove indirection in LanguageModelDawgInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
pnordhus committed Jun 17, 2016
1 parent 034d666 commit b6db68f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions wordrec/language_model.cpp
Expand Up @@ -796,7 +796,7 @@ LanguageModelDawgInfo *LanguageModel::GenerateDawgInfo(
dawg_args_->permuter = NO_PERM;
} else {
if (parent_vse->dawg_info == NULL) return NULL; // not a dict word path
dawg_args_->active_dawgs = parent_vse->dawg_info->active_dawgs;
dawg_args_->active_dawgs = &parent_vse->dawg_info->active_dawgs;
dawg_args_->permuter = parent_vse->dawg_info->permuter;
}

Expand All @@ -822,8 +822,8 @@ LanguageModelDawgInfo *LanguageModel::GenerateDawgInfo(
int i;
// Check a that the path terminated before the current character is a word.
bool has_word_ending = false;
for (i = 0; i < parent_vse->dawg_info->active_dawgs->size(); ++i) {
const DawgPosition &pos = (*parent_vse->dawg_info->active_dawgs)[i];
for (i = 0; i < parent_vse->dawg_info->active_dawgs.size(); ++i) {
const DawgPosition &pos = parent_vse->dawg_info->active_dawgs[i];
const Dawg *pdawg = pos.dawg_index < 0
? NULL : dict_->GetDawg(pos.dawg_index);
if (pdawg == NULL || pos.back_to_punc) continue;;
Expand Down
10 changes: 3 additions & 7 deletions wordrec/lm_state.h
Expand Up @@ -59,13 +59,9 @@ typedef unsigned char LanguageModelFlagsType;
/// component. It stores the set of active dawgs in which the sequence of
/// letters on a path can be found.
struct LanguageModelDawgInfo {
LanguageModelDawgInfo(DawgPositionVector *a, PermuterType pt) : permuter(pt) {
active_dawgs = new DawgPositionVector(*a);
}
~LanguageModelDawgInfo() {
delete active_dawgs;
}
DawgPositionVector *active_dawgs;
LanguageModelDawgInfo(const DawgPositionVector *a, PermuterType pt)
: active_dawgs(*a), permuter(pt) {}
DawgPositionVector active_dawgs;
PermuterType permuter;
};

Expand Down

0 comments on commit b6db68f

Please sign in to comment.