From 295468ac59aa9c92272933bda91d4a495d559259 Mon Sep 17 00:00:00 2001 From: Yu Xiao <1918256943@qq.com> Date: Thu, 23 May 2024 15:24:48 +0800 Subject: [PATCH] Fixes #4247: remove unnecessary nullptr checks --- src/lstm/recodebeam.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lstm/recodebeam.cpp b/src/lstm/recodebeam.cpp index 2a8a0fcdca..1b6710432c 100644 --- a/src/lstm/recodebeam.cpp +++ b/src/lstm/recodebeam.cpp @@ -899,14 +899,11 @@ void RecodeBeamSearch::ContinueContext( bool use_dawgs = IsDawgFromBeamsIndex(index); NodeContinuation prev_cont = ContinuationFromBeamsIndex(index); for (int p = length - 1; p >= 0; --p, previous = previous->prev) { - while (previous != nullptr && - (previous->duplicate || previous->code == null_char_)) { + while (previous->duplicate || previous->code == null_char_) { previous = previous->prev; } - if (previous != nullptr) { - prefix.Set(p, previous->code); - full_code.Set(p, previous->code); - } + prefix.Set(p, previous->code); + full_code.Set(p, previous->code); } if (prev != nullptr && !is_simple_text_) { if (top_n_flags_[prev->code] == top_n_flag) {