st-theme: Optimize string_in_list
Rather than using a complicated set of function calls across library boundaries and our own scanning logic, use strtok(), which glibc already provides, and is probably much more optimized. https://bugzilla.gnome.org/show_bug.cgi?id=687465
This commit is contained in:
parent
d88002c4ed
commit
73b4a0ef5f
@ -450,26 +450,26 @@ static gboolean
|
|||||||
string_in_list (GString *stryng,
|
string_in_list (GString *stryng,
|
||||||
const char *list)
|
const char *list)
|
||||||
{
|
{
|
||||||
const char *cur;
|
char *cur;
|
||||||
|
char *l = g_strdup (list);
|
||||||
|
char *temp;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
for (cur = list; *cur;)
|
cur = strtok_r (l, " \t\f\r\n", &temp);
|
||||||
|
while (cur != NULL)
|
||||||
{
|
{
|
||||||
while (*cur && cr_utils_is_white_space (*cur))
|
if (!strqcmp (cur, stryng->str, stryng->len))
|
||||||
cur++;
|
|
||||||
|
|
||||||
if (strncmp (cur, stryng->str, stryng->len) == 0)
|
|
||||||
{
|
{
|
||||||
cur += stryng->len;
|
found = TRUE;
|
||||||
if ((!*cur) || cr_utils_is_white_space (*cur))
|
goto out;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip to next whitespace character */
|
cur = strtok_r (NULL, " \t\f\r\n", &temp);
|
||||||
while (*cur && !cr_utils_is_white_space (*cur))
|
|
||||||
cur++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
out:
|
||||||
|
g_free (l);
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user