diff options
author | David Robillard <d@drobilla.net> | 2022-12-10 13:54:51 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-12-10 19:04:45 -0500 |
commit | 0791512fb1d73ea63c98f3f68327dc543e214850 (patch) | |
tree | 034a6028b0c9215bd234a3ad95ce2c8ce2609f21 | |
parent | b917c984b15a9583326fa6318be6632850817994 (diff) | |
download | lilv-0791512fb1d73ea63c98f3f68327dc543e214850.tar.gz lilv-0791512fb1d73ea63c98f3f68327dc543e214850.tar.bz2 lilv-0791512fb1d73ea63c98f3f68327dc543e214850.zip |
Avoid cloned conditional branches
-rw-r--r-- | src/.clang-tidy | 1 | ||||
-rw-r--r-- | src/query.c | 7 | ||||
-rw-r--r-- | src/util.c | 7 |
3 files changed, 4 insertions, 11 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy index 21665f3..12ca76c 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -4,7 +4,6 @@ Checks: > -*-magic-numbers, -android-cloexec-fopen, - -bugprone-branch-clone, -bugprone-narrowing-conversions, -cert-err33-c, -cert-err34-c, diff --git a/src/query.c b/src/query.c index 5d916d6..3dd8eca 100644 --- a/src/query.c +++ b/src/query.c @@ -83,12 +83,7 @@ lilv_nodes_from_stream_objects_i18n(LilvWorld* world, } const SordNode* best = nolang; - if (syslang && partial) { - // Partial language match for system language - best = partial; - } else if (!best) { - // No languages matches at all, and no untranslated value - // Use any value, if possible + if ((syslang && partial) || !best) { best = partial; } @@ -116,10 +116,9 @@ lilv_get_lang(void) lang[i] = '-'; // Convert _ to - } else if (env_lang[i] >= 'A' && env_lang[i] <= 'Z') { lang[i] = env_lang[i] + ('a' - 'A'); // Convert to lowercase - } else if (env_lang[i] >= 'a' && env_lang[i] <= 'z') { - lang[i] = env_lang[i]; // Lowercase letter, copy verbatim - } else if (env_lang[i] >= '0' && env_lang[i] <= '9') { - lang[i] = env_lang[i]; // Digit, copy verbatim + } else if ((env_lang[i] >= 'a' && env_lang[i] <= 'z') || + (env_lang[i] >= '0' && env_lang[i] <= '9')) { + lang[i] = env_lang[i]; // Lowercase letter or digit, copy verbatim } else if (env_lang[i] == '\0' || env_lang[i] == '.') { // End, or start of suffix (e.g. en_CA.utf-8), finished lang[i] = '\0'; |