granularity_read: type correction and optimization in _valid_character_check() 98/283298/1
authorMaria Bialota <m.bialota@samsung.com>
Fri, 21 Oct 2022 10:44:13 +0000 (12:44 +0200)
committerMaria Bialota <m.bialota@samsung.com>
Fri, 21 Oct 2022 12:37:29 +0000 (14:37 +0200)
Corrected variable types and in _valid_character_check() function
and optimized number of strlen() calls in the function

Change-Id: I98dd720ea5d650bd5ffdec348cacfc04b1653423

src/granularity_read.c

index 466949383e3371d6de2f45aaa3caa67c8800c5d3..48c6591287e586b530b90372abd143cd8e698e5a 100644 (file)
@@ -46,12 +46,15 @@ static char *_read_character_next_get(char *str, int *start_cursor, int *end_cur
 static Eina_Bool _valid_character_check(char *text, const char *check_buf)
 {
        DEBUG("START");
-       int i = 0;
-       int j = 0;
+
        if (!text)
                return EINA_FALSE;
-       for (i = 0; i < strlen(check_buf); i++)
-               for (j = 0; j < strlen(text); j++)
+
+       size_t check_buf_len = strlen(check_buf);
+       size_t text_len = strlen(text);
+
+       for (size_t i = 0; i < check_buf_len; i++)
+               for (size_t j = 0; j < text_len; j++)
                        if (text[j] == check_buf[i])
                                return EINA_FALSE;
        DEBUG("END");