Factorization of comparaison by using memcmp
This commit is contained in:
1 parent
85ea1f40dc
commit
de2268c406
1 file changed
+1
-5
+1
-5
@@ -1121,11 +1121,7 @@ string_end_with_str_p(const string_t v, const char str[])
|
|||||||
const size_t str_l = strlen(str);
|
const size_t str_l = strlen(str);
|
||||||
if (v_l < str_l)
|
if (v_l < str_l)
|
||||||
return false;
|
return false;
|
||||||
for(size_t i = 0; i < str_l; i++) {
|
return (memcmp(str, &v_str[v_l - str_l], str_l) == 0);
|
||||||
if (str[i] != v_str[v_l - str_l + i])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test if the string ends with the other string */
|
/* Test if the string ends with the other string */
|
||||||
|
|||||||
Reference in new issue
Block a user