mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
check_uri_file(): optimize by not using strlen() more than needed.
This commit is contained in:
parent
9183e0cf04
commit
eda6529ced
@ -151,21 +151,17 @@ check_uri_file(unsigned char *name)
|
|||||||
/* Check POST_CHAR etc ... */
|
/* Check POST_CHAR etc ... */
|
||||||
static const unsigned char chars[] = POST_CHAR_S "#?";
|
static const unsigned char chars[] = POST_CHAR_S "#?";
|
||||||
int i;
|
int i;
|
||||||
|
int namelen = strlen(name);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(chars) - 1; i++) {
|
for (i = 0; i < sizeof(chars) - 1; i++) {
|
||||||
unsigned char *pos = strchr(name, chars[i]);
|
unsigned char *pos = memchr(name, chars[i], namelen);
|
||||||
int namelen;
|
|
||||||
|
|
||||||
if (!pos) continue;
|
if (!pos) continue;
|
||||||
|
|
||||||
*pos = 0;
|
return pos - name;
|
||||||
namelen = strlen(name);
|
|
||||||
*pos = chars[i];
|
|
||||||
|
|
||||||
return namelen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return strlen(name);
|
return namelen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encodes URIs without encoding stuff like fragments and query separators. */
|
/* Encodes URIs without encoding stuff like fragments and query separators. */
|
||||||
|
Loading…
Reference in New Issue
Block a user