From 14d1b5fbd009e48cb5cd1b5f4bee76680646b5f5 Mon Sep 17 00:00:00 2001 From: oga Date: Sun, 18 May 2008 19:34:09 +0000 Subject: 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@ --- parse.y | 54 +++++++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index c2ae94c..aa17c4e 100644 --- a/parse.y +++ b/parse.y @@ -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 @@ -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); } -- cgit v1.2.3-2-gb3c3