diff --git a/src/lstm/recodebeam.cpp b/src/lstm/recodebeam.cpp index 89d95caedb..05d38ee0a2 100644 --- a/src/lstm/recodebeam.cpp +++ b/src/lstm/recodebeam.cpp @@ -891,15 +891,13 @@ void RecodeBeamSearch::ContinueContext( int length = LengthFromBeamsIndex(index); 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_)) { + for (int p = length - 1; p >= 0 && previous != nullptr; --p) { + 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); + previous = previous->prev; } if (prev != nullptr && !is_simple_text_) { if (top_n_flags_[prev->code] == top_n_flag) { diff --git a/src/training/unicharset/fileio.cpp b/src/training/unicharset/fileio.cpp index 84aa2400d1..fe0e8d0d49 100644 --- a/src/training/unicharset/fileio.cpp +++ b/src/training/unicharset/fileio.cpp @@ -71,7 +71,7 @@ bool File::Readable(const std::string &filename) { } bool File::ReadFileToString(const std::string &filename, std::string *out) { - FILE *stream = File::Open(filename.c_str(), "rb"); + FILE *stream = File::Open(filename, "rb"); if (stream == nullptr) { return false; } diff --git a/src/training/unicharset/lang_model_helpers.cpp b/src/training/unicharset/lang_model_helpers.cpp index d968e674d6..7e0adc2c0b 100644 --- a/src/training/unicharset/lang_model_helpers.cpp +++ b/src/training/unicharset/lang_model_helpers.cpp @@ -129,7 +129,7 @@ bool WriteRecoder(const UNICHARSET &unicharset, bool pass_through, const std::st std::string suffix; suffix += ".charset_size=" + std::to_string(recoder.code_range()); suffix += ".txt"; - return WriteFile(output_dir, lang, suffix.c_str(), recoder_data, writer); + return WriteFile(output_dir, lang, suffix, recoder_data, writer); } // Helper builds a dawg from the given words, using the unicharset as coding,