mu-fields: const correctness, o18n

Don't copy strings when unneeded.
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-23 11:36:33 +03:00
committed by Seth Ladygo
parent 8208639c49
commit f9ad65423e
2 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -61,7 +61,7 @@ Mu::fields_from_name(const std::string& name) {
static const FieldsVec empty; static const FieldsVec empty;
const auto& cfields{combi_fields()}; const auto& cfields{combi_fields()};
const auto it = seq_find_if(cfields, [&](auto cfield) { const auto it = seq_find_if(cfields, [&](const auto& cfield) {
return cfield.name == name; return cfield.name == name;
}); });
@ -71,7 +71,7 @@ Mu::fields_from_name(const std::string& name) {
bool bool
Mu::field_is_combi(const std::string& name) Mu::field_is_combi(const std::string& name)
{ {
return name != "" && seq_some(combi_fields(),[&](auto cfield) { return !name.empty() && seq_some(combi_fields(),[&](const auto& cfield) {
return cfield.name == name; return cfield.name == name;
}); });
} }
@ -165,7 +165,9 @@ validate_field_flags()
* tests... also build as runtime-tests, so we can get coverage info * tests... also build as runtime-tests, so we can get coverage info
*/ */
#ifdef BUILD_TESTS #ifdef BUILD_TESTS
#define static_assert g_assert_true #define static_test g_assert_true
#else
#define static_test static_assert
#endif /*BUILD_TESTS*/ #endif /*BUILD_TESTS*/
@ -173,28 +175,28 @@ validate_field_flags()
static void static void
test_ids() test_ids()
{ {
static_assert(validate_field_ids()); static_test(validate_field_ids());
} }
[[maybe_unused]] [[maybe_unused]]
static void static void
test_shortcuts() test_shortcuts()
{ {
static_assert(validate_field_shortcuts()); static_test(validate_field_shortcuts());
} }
[[maybe_unused]] [[maybe_unused]]
static void static void
test_prefix() test_prefix()
{ {
static_assert(field_from_id(Field::Id::Subject).xapian_prefix() == 'S'); static_test(field_from_id(Field::Id::Subject).xapian_prefix() == 'S');
} }
[[maybe_unused]] [[maybe_unused]]
static void static void
test_field_flags() test_field_flags()
{ {
static_assert(validate_field_flags()); static_test(validate_field_flags());
} }
#ifdef BUILD_TESTS #ifdef BUILD_TESTS

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the