util/stringops: use strncmp for strendswith (#362)

Minor change, doesn't really fix anything.

Similar to strstartswith, it may be better to use strncmp instead of
looping through every char in a string.
This commit is contained in:
Nhalrath 2023-04-18 02:06:42 -07:00 committed by GitHub
parent a5678791a4
commit 2d47ab0fe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,11 +19,7 @@ bool strendswith(const char *s, const char *e) {
if(le > ls)
return false;
int i; for(i = 0; i < le; ++i)
if(s[ls-i-1] != e[le-i-1])
return false;
return true;
return !strncmp(s+ls-le, e, le);
}
bool strstartswith(const char *s, const char *p) {