[gnome-shell] theme-node: Rewrite switch statement



commit c3a29d6df153667b8ded2302e4342f56e538d337
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Sep 23 20:00:23 2015 +0200

    theme-node: Rewrite switch statement
    
    Some compilers warn about unhandled enum values in switch statements,
    so don't use one where only two out of 21 possible values make sense.

 src/st/st-theme-node.c |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 4c8fabd..c109bae 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -840,26 +840,21 @@ st_theme_node_lookup_time (StThemeNode *node,
       if (strcmp (decl->property->stryng->str, property_name) == 0)
         {
           CRTerm *term = decl->value;
+          int factor = 1;
 
           if (term->type != TERM_NUMBER)
             continue;
 
-          switch (term->content.num->type)
-            {
-            case NUM_TIME_S:
-              *value = 1000 * term->content.num->val;
-              result = TRUE;
-              break;
-            case NUM_TIME_MS:
-              *value = term->content.num->val;
-              result = TRUE;
-              break;
-            default:
-              ;
-            }
+          if (term->content.num->type != NUM_TIME_S ||
+              term->content.num->type != NUM_TIME_MS)
+            continue;
 
-          if (result)
-            break;
+          if (term->content.num->type == NUM_TIME_S)
+            factor = 1000;
+
+          *value = factor * term->content.num->val;
+          result = TRUE;
+          break;
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]