[gnome-network-displays/cc-tmp: 72/80] cc: waiting_for optimization



commit cd4240208e5a95003508dfe827c7aca61a91085f
Author: Anupam Kumar <kyteinsky gmail com>
Date:   Tue Sep 6 15:13:53 2022 +0530

    cc: waiting_for optimization

 src/cc/cc-common.h | 20 ++++++++++----------
 src/cc/cc-ctrl.c   |  6 +++---
 src/cc/cc-ctrl.h   |  2 +-
 3 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/cc/cc-common.h b/src/cc/cc-common.h
index c4901b1..35fec9f 100644
--- a/src/cc/cc-common.h
+++ b/src/cc/cc-common.h
@@ -47,16 +47,16 @@ G_BEGIN_DECLS
 
 
 typedef enum {
-  CC_RWAIT_TYPE_NONE                 = 0,
-  CC_RWAIT_TYPE_GET_APP_AVAILABILITY = 1 << 0, /* key is `responseType` */
-  CC_RWAIT_TYPE_LAUNCH_ERROR         = 1 << 1, /* all other keys are `type` */
-  CC_RWAIT_TYPE_ANSWER               = 1 << 2,
-  CC_RWAIT_TYPE_RECEIVER_STATUS      = 1 << 3,
-  CC_RWAIT_TYPE_MEDIA_STATUS         = 1 << 4,
-  CC_RWAIT_TYPE_PING                 = 1 << 5,
-  CC_RWAIT_TYPE_PONG                 = 1 << 6,
-  CC_RWAIT_TYPE_CLOSE                = 1 << 7,
-  CC_RWAIT_TYPE_UNKNOWN              = 1 << 8,
+  CC_RWAIT_TYPE_NONE = 0,
+  CC_RWAIT_TYPE_GET_APP_AVAILABILITY, /* key is `responseType` */
+  CC_RWAIT_TYPE_LAUNCH_ERROR, /* all other keys are `type` */
+  CC_RWAIT_TYPE_ANSWER,
+  CC_RWAIT_TYPE_RECEIVER_STATUS,
+  CC_RWAIT_TYPE_MEDIA_STATUS,
+  CC_RWAIT_TYPE_PING,
+  CC_RWAIT_TYPE_PONG,
+  CC_RWAIT_TYPE_CLOSE,
+  CC_RWAIT_TYPE_UNKNOWN,
 } CcReceivedMessageType;
 
 typedef CcReceivedMessageType CcWaitingFor;
diff --git a/src/cc/cc-ctrl.c b/src/cc/cc-ctrl.c
index 2025145..dfe5032 100644
--- a/src/cc/cc-ctrl.c
+++ b/src/cc/cc-ctrl.c
@@ -27,19 +27,19 @@ static void cc_ctrl_fatal_error (CcCtrl *ctrl);
 static void
 cc_ctrl_set_waiting_for (CcCtrl *ctrl, CcWaitingFor waiting_for)
 {
-  ctrl->waiting_for |= waiting_for;
+  ctrl->waiting_for |= 1 << waiting_for;
 }
 
 static void
 cc_ctrl_unset_waiting_for (CcCtrl *ctrl, CcWaitingFor waiting_for)
 {
-  ctrl->waiting_for &= ~waiting_for;
+  ctrl->waiting_for &= ~(1 << waiting_for);
 }
 
 static gboolean
 cc_ctrl_is_waiting_for (CcCtrl *ctrl, CcWaitingFor waiting_for)
 {
-  return (ctrl->waiting_for & waiting_for) > CC_RWAIT_TYPE_NONE;
+  return (ctrl->waiting_for & (1 << waiting_for)) > 1 << CC_RWAIT_TYPE_NONE;
 }
 
 /* SEND HELPER FUNCTIONS */
diff --git a/src/cc/cc-ctrl.h b/src/cc/cc-ctrl.h
index b905362..2de54dc 100644
--- a/src/cc/cc-ctrl.h
+++ b/src/cc/cc-ctrl.h
@@ -57,7 +57,7 @@ struct _CcCtrl
   CcCtrlState state;
   gchar      *session_id;
   guint       request_id;
-  guint8      waiting_for;
+  guint       waiting_for;
   guint       ping_timeout_handle;
   guint       waiting_check_timeout_handle;
 };


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