Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 10 Dec 2023 21:50:59 UTC Commit: effe633ef710c690eeff4bb37ce5ce1d13d1c8fc https://github.com/geany/geany/commit/effe633ef710c690eeff4bb37ce5ce1d13d1c8...
Log Message: ----------- Small code cleanup
Use more idiomatic loops.
Modified Paths: -------------- src/encodings.c
Modified: src/encodings.c 18 lines changed, 3 insertions(+), 15 deletions(-) =================================================================== @@ -195,37 +195,27 @@ static gboolean encodings_charset_equals(const gchar *a, const gchar *b)
GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset) { - gint i; - if (charset == NULL) return GEANY_ENCODING_UTF_8;
- i = 0; - while (i < GEANY_ENCODINGS_MAX) + for (gint i = 0; i < GEANY_ENCODINGS_MAX; i++) { if (encodings_charset_equals(charset, encodings[i].charset)) return i; - - ++i; } return GEANY_ENCODING_UTF_8; }
const GeanyEncoding *encodings_get_from_charset(const gchar *charset) { - gint i; - if (charset == NULL) return &encodings[GEANY_ENCODING_UTF_8];
- i = 0; - while (i < GEANY_ENCODINGS_MAX) + for (gint i = 0; i < GEANY_ENCODINGS_MAX; i++) { if (encodings_charset_equals(charset, encodings[i].charset)) return &encodings[i]; - - ++i; }
return NULL; @@ -300,12 +290,10 @@ void encodings_select_radio_item(const gchar *charset)
g_return_if_fail(charset != NULL);
- i = 0; - while (i < GEANY_ENCODINGS_MAX) + for (i = 0; i < GEANY_ENCODINGS_MAX; i++) { if (utils_str_equal(charset, encodings[i].charset)) break; - i++; } if (i == GEANY_ENCODINGS_MAX) i = GEANY_ENCODING_UTF_8; /* fallback to UTF-8 */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).