diff options
author | oga <oga> | 2008-05-18 19:34:09 +0000 |
---|---|---|
committer | oga <oga> | 2008-05-18 19:34:09 +0000 |
commit | a21a064a9b0d15239f72d5e6d5d9181fc387a427 (patch) | |
tree | 25789a9035373d07fc15569355db2adf6dd50496 | |
parent | 0f50af616e623455a6a00d941c33886be0e96486 (diff) | |
download | cwm-a21a064a9b0d15239f72d5e6d5d9181fc387a427.tar.gz cwm-a21a064a9b0d15239f72d5e6d5d9181fc387a427.tar.xz cwm-a21a064a9b0d15239f72d5e6d5d9181fc387a427.zip |
When we're cleaning out the lists in parse_config and conf_clear it's a
lot simpler just to do while (entry = TAILQ_FIRST(head)) than to do a for () over the whole lot. Simpler, shorter and probably faster. ok okan@
-rw-r--r-- | parse.y | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/parse.y b/parse.y index e6519ff..b9b9222 100644 --- a/parse.y +++ b/parse.y @@ -466,28 +466,22 @@ popfile(void) void conf_clear(struct conf *c) { - struct autogroupwin *ag, *agnext; - struct keybinding *kb, *kbnext; - struct winmatch *wm, *wmnext; - struct cmd *cmd, *cmdnext; - - for (cmd = TAILQ_FIRST(&c->cmdq); cmd != NULL; cmd = cmdnext) { - cmdnext = TAILQ_NEXT(cmd, entry); + struct autogroupwin *ag; + struct keybinding *kb; + struct winmatch *wm; + struct cmd *cmd; + while (cmd = TAILQ_FIRST(&c->cmdq)) { TAILQ_REMOVE(&c->cmdq, cmd, entry); free(cmd); } - for (kb = TAILQ_FIRST(&c->keybindingq); kb != NULL; kb = kbnext) { - kbnext = TAILQ_NEXT(kb, entry); - + while (kb = TAILQ_FIRST(&c->keybindingq)) { TAILQ_REMOVE(&c->keybindingq, kb, entry); free(kb); } - for (ag = TAILQ_FIRST(&c->autogroupq); ag != NULL; ag = agnext) { - agnext = TAILQ_NEXT(ag, entry); - + while (ag = TAILQ_FIRST(&c->autogroupq)) { TAILQ_REMOVE(&c->autogroupq, ag, entry); free(ag->class); if (ag->name) @@ -496,9 +490,7 @@ conf_clear(struct conf *c) free(ag); } - for (wm = TAILQ_FIRST(&c->ignoreq); wm != NULL; wm = wmnext) { - wmnext = TAILQ_NEXT(wm, entry); - + while (wm = TAILQ_FIRST(&c->ignoreq)) { TAILQ_REMOVE(&c->ignoreq, wm, entry); free(wm); } @@ -534,43 +526,31 @@ parse_config(const char *filename, struct conf *xconf) conf_clear(conf); } else { - struct autogroupwin *ag, *agnext; - struct keybinding *kb, *kbnext; - struct winmatch *wm, *wmnext; - struct cmd *cmd, *cmdnext; + struct autogroupwin *ag; + struct keybinding *kb; + struct winmatch *wm; + struct cmd *cmd; conf_clear(xconf); xconf->flags = conf->flags; - for (cmd = TAILQ_FIRST(&conf->cmdq); cmd != NULL; - cmd = cmdnext) { - cmdnext = TAILQ_NEXT(cmd, entry); - + while (cmd = TAILQ_FIRST(&conf->cmdq)) { TAILQ_REMOVE(&conf->cmdq, cmd, entry); TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry); } - for (kb = TAILQ_FIRST(&conf->keybindingq); kb != NULL; - kb = kbnext) { - kbnext = TAILQ_NEXT(kb, entry); - + while (kb = TAILQ_FIRST(&conf->keybindingq)) { TAILQ_REMOVE(&conf->keybindingq, kb, entry); TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry); } - for (ag = TAILQ_FIRST(&conf->autogroupq); ag != NULL; - ag = agnext) { - agnext = TAILQ_NEXT(ag, entry); - + while (ag = TAILQ_FIRST(&conf->autogroupq)) { TAILQ_REMOVE(&conf->autogroupq, ag, entry); TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry); } - for (wm = TAILQ_FIRST(&conf->ignoreq); wm != NULL; - wm = wmnext) { - wmnext = TAILQ_NEXT(wm, entry); - + while (wm = TAILQ_FIRST(&conf->ignoreq)) { TAILQ_REMOVE(&conf->ignoreq, wm, entry); TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry); } |