JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied Szabolcs proposal to simplify setlayout()
[dwm.git] / layout.c
index 5bb6e97..47e9e49 100644 (file)
--- a/layout.c
+++ b/layout.c
@@ -198,11 +198,9 @@ setlayout(const char *arg) {
        int i;
 
        if(!arg) {
-               for(i = 0; i < nlayouts && lt != &layout[i]; i++);
-               if(i == nlayouts - 1)
-                       lt = &layout[0];
-               else
-                       lt = &layout[++i];
+               lt++;
+               if(lt == layout + nlayouts)
+                       lt = layout;
        }
        else {
                i = atoi(arg);
@@ -218,10 +216,8 @@ setlayout(const char *arg) {
 
 void
 togglebar(const char *arg) {
-       if(bpos == BarOff) {
-               if((bpos = BARPOS) == BarOff)
-                       bpos = BarTop;
-       }
+       if(bpos == BarOff)
+               bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
        else
                bpos = BarOff;
        updatebarpos();