diff options
author | oga | 2008-05-18 19:34:09 +0000 |
---|---|---|
committer | oga | 2008-05-18 19:34:09 +0000 |
commit | 14d1b5fbd009e48cb5cd1b5f4bee76680646b5f5 (patch) | |
tree | 8c368db420bc36318e03b5b5d5aaf3f5c30fa24b /parse.y | |
parent | 560d8198cee2b519f51dbf6212e1f15cbfe97dcc (diff) | |
download | cwm-14d1b5fbd009e48cb5cd1b5f4bee76680646b5f5.tar.gz |
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@
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 54 |
1 files changed, 17 insertions, 37 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.6 2008/04/29 20:17:28 simon Exp $ */ +/* $OpenBSD: parse.y,v 1.7 2008/05/18 19:34:09 oga Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -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); } |