mirror of https://github.com/omar-polo/gmid.git
remove not so useful starts_with()
replace its only usage with strncmp(). it's likely faster too.
This commit is contained in:
parent
8bb1b23633
commit
95500a936a
1
gmid.h
1
gmid.h
|
@ -453,7 +453,6 @@ int puny_decode(const char*, char*, size_t, const char**);
|
||||||
|
|
||||||
/* utils.c */
|
/* utils.c */
|
||||||
const char *strip_path(const char *, int);
|
const char *strip_path(const char *, int);
|
||||||
int starts_with(const char*, const char*);
|
|
||||||
int ends_with(const char*, const char*);
|
int ends_with(const char*, const char*);
|
||||||
char *absolutify_path(const char*);
|
char *absolutify_path(const char*);
|
||||||
char *xstrdup(const char*);
|
char *xstrdup(const char*);
|
||||||
|
|
2
puny.c
2
puny.c
|
@ -151,7 +151,7 @@ decode(const char *str, char *out, size_t len, const char **err)
|
||||||
unsigned int numpoints;
|
unsigned int numpoints;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
if (!starts_with(str, "xn--")) {
|
if (strncmp(str, "xn--", 4) != 0) {
|
||||||
strncpy(out, str, len);
|
strncpy(out, str, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
14
utils.c
14
utils.c
|
@ -46,20 +46,6 @@ strip_path(const char *path, int strip)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
starts_with(const char *str, const char *prefix)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (prefix == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; prefix[i] != '\0'; ++i)
|
|
||||||
if (str[i] != prefix[i])
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ends_with(const char *str, const char *sufx)
|
ends_with(const char *str, const char *sufx)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue