aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2013-01-23 14:50:18 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2013-01-23 14:50:18 +0000
commit2792afd090594c80427164d2a2e26f21d3c3d4b2 (patch)
tree859347b934cd01539d33765607352be731273169
parent1ea86978463bf0d9a3e09a0b45fee2eb54bc7d21 (diff)
downloadenlightenment-2792afd090594c80427164d2a2e26f21d3c3d4b2.tar.gz
enlightenment-2792afd090594c80427164d2a2e26f21d3c3d4b2.tar.xz
enlightenment-2792afd090594c80427164d2a2e26f21d3c3d4b2.zip
reduce number of loops required to iterate when updating conf2 option ctx from text
SVN revision: 83178
-rw-r--r--src/bin/e_configure_option.c118
1 files changed, 56 insertions, 62 deletions
diff --git a/src/bin/e_configure_option.c b/src/bin/e_configure_option.c
index f93923c5d..4f06189e4 100644
--- a/src/bin/e_configure_option.c
+++ b/src/bin/e_configure_option.c
@@ -2568,9 +2568,10 @@ e_configure_option_ctx_new(void)
EAPI Eina_Bool
e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
{
- Eina_List *l, *ll, *tlist, *tmp, *clist = NULL;
+ Eina_List *l, *ll, *alist, *tlist, *tmp = NULL, *clist = NULL;
Eina_Stringshare *tag, *alias;
char *s, *e, *update;
+ Eina_Bool skip;
if ((!str) || (!str[0]))
{
@@ -2581,53 +2582,49 @@ e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
}
update = strdupa(str);
eina_str_tolower(&update);
- tlist = eina_list_clone(tags_alias_list);
+ alist = eina_list_clone(tags_alias_list);
+ tlist = eina_list_clone(tags_list);
for (s = e = strdupa(update); e[0]; e++)
{
if (isalnum(e[0])) continue;
e[0] = 0;
- if (e - s > 1)
+ if (e - s <= 1) goto end;
+ tmp = NULL;
+ skip = EINA_FALSE;
+ EINA_LIST_FOREACH_SAFE(alist, l, ll, alias)
{
- tmp = NULL;
- EINA_LIST_FOREACH_SAFE(tlist, l, ll, alias)
+ if ((!strstr(s, alias)) && (!strstr(alias, s))) continue;
+ tag = eina_hash_find(tags_alias_hash, alias);
+ if (clist && eina_list_data_find(clist, tag))
{
- if ((!strstr(s, alias)) && (!strstr(alias, s))) continue;
- tag = eina_hash_find(tags_alias_hash, alias);
- if (eina_list_data_find(clist, tag))
- {
- if (strncmp(s, alias, e - s)) continue;
- tmp = eina_list_free(tmp);
- break;
- }
- tlist = eina_list_remove_list(tlist, l);
- if (strncmp(s, alias, e - s))
- {
- tmp = eina_list_append(tmp, tag);
- continue;
- }
+ if (strncmp(s, alias, e - s)) continue;
tmp = eina_list_free(tmp);
- tmp = eina_list_append(tmp, tag);
+ skip = EINA_TRUE;
break;
}
- if (tmp) clist = eina_list_merge(clist, tmp);
+ alist = eina_list_remove_list(alist, l);
+ if (strncmp(s, alias, e - s))
+ {
+ tmp = eina_list_append(tmp, tag);
+ continue;
+ }
+ tmp = eina_list_free(tmp);
+ tmp = eina_list_append(tmp, tag);
+ skip = EINA_TRUE;
+ break;
}
- s = e + 1;
- }
- if (e - s > 1)
- {
- tmp = NULL;
- EINA_LIST_FOREACH_SAFE(tlist, l, ll, alias)
+ if (skip) goto end;
+ EINA_LIST_FOREACH_SAFE(tlist, l, ll, tag)
{
- if ((!strstr(s, alias)) && (!strstr(alias, s))) continue;
- tag = eina_hash_find(tags_alias_hash, alias);
- if (eina_list_data_find(clist, tag))
+ if ((!strstr(s, tag)) && (!strstr(tag, s))) continue;
+ if (clist && eina_list_data_find(clist, tag))
{
- if (strncmp(s, alias, e - s)) continue;
+ if (strncmp(s, tag, e - s)) continue;
tmp = eina_list_free(tmp);
break;
}
tlist = eina_list_remove_list(tlist, l);
- if (strncmp(s, alias, e - s))
+ if (strncmp(s, tag, e - s))
{
tmp = eina_list_append(tmp, tag);
continue;
@@ -2636,47 +2633,42 @@ e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
tmp = eina_list_append(tmp, tag);
break;
}
+end:
if (tmp) clist = eina_list_merge(clist, tmp);
+ tmp = NULL;
+ s = e + 1;
}
- eina_list_free(tlist);
- tlist = eina_list_clone(tags_list);
- for (s = e = strdupa(update); e[0]; e++)
+ while (e - s > 1)
{
- if (isalnum(e[0])) continue;
- e[0] = 0;
- if (e - s > 1)
+ tmp = NULL;
+ skip = EINA_FALSE;
+ EINA_LIST_FOREACH_SAFE(alist, l, ll, alias)
{
- tmp = NULL;
- EINA_LIST_FOREACH_SAFE(tlist, l, ll, tag)
+ if ((!strstr(s, alias)) && (!strstr(alias, s))) continue;
+ tag = eina_hash_find(tags_alias_hash, alias);
+ if (clist && eina_list_data_find(clist, tag))
{
- if ((!strstr(s, tag)) && (!strstr(tag, s))) continue;
- if (eina_list_data_find(clist, tag))
- {
- if (strncmp(s, tag, e - s)) continue;
- tmp = eina_list_free(tmp);
- break;
- }
- tlist = eina_list_remove_list(tlist, l);
- if (strncmp(s, tag, e - s))
- {
- tmp = eina_list_append(tmp, tag);
- continue;
- }
+ if (strncmp(s, alias, e - s)) continue;
tmp = eina_list_free(tmp);
- tmp = eina_list_append(tmp, tag);
+ skip = EINA_TRUE;
break;
}
- if (tmp) clist = eina_list_merge(clist, tmp);
+ alist = eina_list_remove_list(alist, l);
+ if (strncmp(s, alias, e - s))
+ {
+ tmp = eina_list_append(tmp, tag);
+ continue;
+ }
+ tmp = eina_list_free(tmp);
+ tmp = eina_list_append(tmp, tag);
+ skip = EINA_TRUE;
+ break;
}
- s = e + 1;
- }
- if (e - s > 1)
- {
- tmp = NULL;
+ if (skip) break;
EINA_LIST_FOREACH_SAFE(tlist, l, ll, tag)
{
if ((!strstr(s, tag)) && (!strstr(tag, s))) continue;
- if (eina_list_data_find(clist, tag))
+ if (clist && eina_list_data_find(clist, tag))
{
if (strncmp(s, tag, e - s)) continue;
tmp = eina_list_free(tmp);
@@ -2692,8 +2684,10 @@ e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
tmp = eina_list_append(tmp, tag);
break;
}
- if (tmp) clist = eina_list_merge(clist, tmp);
+ break;
}
+ if (tmp) clist = eina_list_merge(clist, tmp);
+ eina_list_free(alist);
eina_list_free(tlist);
if (eina_list_count(clist) != eina_list_count(ctx->tags))
goto update;