Skip to content

Commit

Permalink
[Fix] Set loaded variable explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Nov 13, 2023
1 parent 0be20c4 commit b661260
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libmime/lang_detection_fasttext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class fasttext_langdet {
private:
fasttext::FastText ft;
std::string model_fname;
bool loaded;
bool loaded = false;

public:
explicit fasttext_langdet(struct rspamd_config *cfg)
Expand Down Expand Up @@ -124,10 +124,11 @@ class fasttext_langdet {
return predictions;
}

auto model_info(void) const -> std::string
auto model_info(void) const -> const std::string
{
if (!loaded) {
return "fasttext model is not loaded";
static const auto not_loaded = std::string{"fasttext model is not loaded"};
return not_loaded;
}
else {
return fmt::format("fasttext model {}: {} languages, {} tokens", model_fname,
Expand Down

0 comments on commit b661260

Please sign in to comment.