[devhelp/wip/swilmet/fix-warnings] Book: change switch to if/else if



commit 4b413b6ccee404ac19eb23e1eaa78e04742eb7f2
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Nov 27 12:34:53 2016 +0100

    Book: change switch to if/else if
    
    I think it is here appropriate to have if/else if, because there are
    many enum values (not defined in Devhelp). We are only interested by 3
    events.

 src/dh-book.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/src/dh-book.c b/src/dh-book.c
index 81fa071..ca5efa4 100644
--- a/src/dh-book.c
+++ b/src/dh-book.c
@@ -349,23 +349,17 @@ book_monitor_event_cb (GFileMonitor      *file_monitor,
         DhBookPrivate *priv = dh_book_get_instance_private (book);
         gboolean    reset_timer = FALSE;
 
-        switch (event_type) {
-        case G_FILE_MONITOR_EVENT_CREATED:
-                /* This may happen if the file is deleted and then
-                 * created right away, as we're merging events.
-                 * Treat in the same way as a CHANGES_DONE_HINT, so
-                 * fall through the case.  */
-        case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+        /* CREATED may happen if the file is deleted and then created right
+         * away, as we're merging events.  Treat in the same way as a
+         * CHANGES_DONE_HINT.
+         */
+        if (event_type == G_FILE_MONITOR_EVENT_CREATED ||
+            event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
                 priv->monitor_event = BOOK_MONITOR_EVENT_UPDATED;
                 reset_timer = TRUE;
-                break;
-        case G_FILE_MONITOR_EVENT_DELETED:
+        } else if (event_type == G_FILE_MONITOR_EVENT_DELETED) {
                 priv->monitor_event = BOOK_MONITOR_EVENT_DELETED;
                 reset_timer = TRUE;
-                break;
-        default:
-                /* Ignore all the other events */
-                break;
         }
 
         /* Reset timer if any of the flags changed */


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