From a797582e89c811ad3b1ecad804f3e8ed8a293bac Mon Sep 17 00:00:00 2001 From: XapaJIaMnu Date: Fri, 13 Jun 2014 17:02:08 +0100 Subject: [PATCH] Remove more unnecessary dynamic casts --- moses/FF/LexicalReordering/LexicalReordering.cpp | 2 +- moses/FF/LexicalReordering/LexicalReorderingState.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/moses/FF/LexicalReordering/LexicalReordering.cpp b/moses/FF/LexicalReordering/LexicalReordering.cpp index 6a2a488d9..5a9758398 100644 --- a/moses/FF/LexicalReordering/LexicalReordering.cpp +++ b/moses/FF/LexicalReordering/LexicalReordering.cpp @@ -71,7 +71,7 @@ FFState* LexicalReordering::Evaluate(const Hypothesis& hypo, ScoreComponentCollection* out) const { Scores score(GetNumScoreComponents(), 0); - const LexicalReorderingState *prev = dynamic_cast(prev_state); + const LexicalReorderingState *prev = static_cast(prev_state); LexicalReorderingState *next_state = prev->Expand(hypo.GetTranslationOption(), score); out->PlusEquals(this, score); diff --git a/moses/FF/LexicalReordering/LexicalReorderingState.cpp b/moses/FF/LexicalReordering/LexicalReorderingState.cpp index dbfddd3f9..6e8647837 100644 --- a/moses/FF/LexicalReordering/LexicalReorderingState.cpp +++ b/moses/FF/LexicalReordering/LexicalReorderingState.cpp @@ -291,7 +291,7 @@ int BidirectionalReorderingState::Compare(const FFState& o) const if (&o == this) return 0; - const BidirectionalReorderingState &other = dynamic_cast(o); + const BidirectionalReorderingState &other = static_cast(o); if(m_backward->Compare(*other.m_backward) < 0) return -1; else if(m_backward->Compare(*other.m_backward) > 0) @@ -320,7 +320,7 @@ HierarchicalReorderingBackwardState::HierarchicalReorderingBackwardState(const L int HierarchicalReorderingBackwardState::Compare(const FFState& o) const { - const HierarchicalReorderingBackwardState& other = dynamic_cast(o); + const HierarchicalReorderingBackwardState& other = static_cast(o); return m_reoStack.Compare(other.m_reoStack); } @@ -406,8 +406,7 @@ int HierarchicalReorderingForwardState::Compare(const FFState& o) const if (&o == this) return 0; - const HierarchicalReorderingForwardState* other = dynamic_cast(&o); - UTIL_THROW_IF2(other == NULL, "Wrong state type"); + const HierarchicalReorderingForwardState* other = static_cast(&o); if (m_prevRange == other->m_prevRange) { return ComparePrevScores(other->m_prevScore);