[gnome-shell] st-theme: Optimize string_in_list
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-theme: Optimize string_in_list
- Date: Mon, 5 Nov 2012 20:10:56 +0000 (UTC)
commit 73b4a0ef5f4ca29c35c359e29dc0e198c7feb51e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Nov 5 13:36:40 2012 -0500
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
src/st/st-theme.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/src/st/st-theme.c b/src/st/st-theme.c
index 77076c0..298cdc8 100644
--- a/src/st/st-theme.c
+++ b/src/st/st-theme.c
@@ -450,26 +450,26 @@ static gboolean
string_in_list (GString *stryng,
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))
- cur++;
-
- if (strncmp (cur, stryng->str, stryng->len) == 0)
+ if (!strqcmp (cur, stryng->str, stryng->len))
{
- cur += stryng->len;
- if ((!*cur) || cr_utils_is_white_space (*cur))
- return TRUE;
+ found = TRUE;
+ goto out;
}
- /* skip to next whitespace character */
- while (*cur && !cr_utils_is_white_space (*cur))
- cur++;
+ cur = strtok_r (NULL, " \t\f\r\n", &temp);
}
- return FALSE;
+ out:
+ g_free (l);
+ return found;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]