Skip to content

Commit

Permalink
xapian_wrap.cpp:parse_doclangs() check for val.empty() only once
Browse files Browse the repository at this point in the history
It was checked before and within the function call, whether val is empty.
  • Loading branch information
dilyanpalauzov committed Aug 19, 2023
1 parent bb6a880 commit 791a4ae
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions imap/xapian_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ static void read_language_counts(const Xapian::Database& db,

static void parse_doclangs(const std::string& val, std::set<std::string>& doclangs)
{
if (val.empty() || !isalpha(val[0])) return;

size_t base = 0, pos;
while ((pos = val.find(',', base)) != std::string::npos) {
doclangs.insert(val.substr(base, pos - base));
Expand Down Expand Up @@ -2310,7 +2308,7 @@ EXPORTED int xapian_snipgen_doc_part(xapian_snipgen_t *snipgen,
std::string key = lang_doc_key(snipgen->cyrusid);
for (const Xapian::Database& subdb : *snipgen->db->subdbs) {
std::string val = subdb.get_metadata(key);
if (!val.empty()) parse_doclangs(val, doclangs);
if (!val.empty() && isalpha(val[0])) parse_doclangs(val, doclangs);
break;
}

Expand Down

0 comments on commit 791a4ae

Please sign in to comment.