stop using bool as index for an unnecessary uninitialized array 69/28069/2
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 25 Sep 2014 14:26:46 +0000 (15:26 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 25 Sep 2014 14:30:05 +0000 (15:30 +0100)
[Problem] bad code
[Cause]
[Solution] fix it

Change-Id: I9d44609e1125ede5c5aecff7755452e17994d67b

dali/internal/update/common/scene-graph-property-notification.cpp
dali/internal/update/common/scene-graph-property-notification.h

index 6c49499..2396fda 100644 (file)
@@ -61,7 +61,8 @@ PropertyNotification::PropertyNotification(ProxyObject& proxy,
   mComponentIndex(componentIndex),
   mConditionType(condition),
   mArguments(arguments),
-  mValid(false)
+  mValid(false),
+  mNotifyMode( Dali::PropertyNotification::Disabled )
 {
   SetNotifyMode(notifyMode);
 
@@ -124,33 +125,7 @@ bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgum
 
 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
 {
-  switch(notifyMode)
-  {
-    case Dali::PropertyNotification::Disabled:
-    {
-      mNotifyValidity[0] = false;
-      mNotifyValidity[1] = false;
-      break;
-    }
-    case Dali::PropertyNotification::NotifyOnTrue:
-    {
-      mNotifyValidity[0] = false;
-      mNotifyValidity[1] = true;
-      break;
-    }
-    case Dali::PropertyNotification::NotifyOnFalse:
-    {
-      mNotifyValidity[0] = true;
-      mNotifyValidity[1] = false;
-      break;
-    }
-    case Dali::PropertyNotification::NotifyOnChanged:
-    {
-      mNotifyValidity[0] = true;
-      mNotifyValidity[1] = true;
-      break;
-    }
-  }
+  mNotifyMode = notifyMode;
 }
 
 bool PropertyNotification::Check( BufferIndex bufferIndex )
@@ -177,7 +152,30 @@ bool PropertyNotification::Check( BufferIndex bufferIndex )
                         || (mConditionType == PropertyCondition::VariableStep))) )
   {
     mValid = currentValid;
-    notifyRequired = mNotifyValidity[currentValid];
+    //  means don't notify so notifyRequired stays false
+    switch( mNotifyMode )
+    {
+      case Dali::PropertyNotification::Disabled:
+      {
+        // notify never, already initialized to false
+        break;
+      }
+      case Dali::PropertyNotification::NotifyOnTrue:
+      {
+        notifyRequired = mValid; // notify if value is true
+        break;
+      }
+      case Dali::PropertyNotification::NotifyOnFalse:
+      {
+        notifyRequired = !mValid; // notify when its false
+        break;
+      }
+      case Dali::PropertyNotification::NotifyOnChanged:
+      {
+        notifyRequired = true; // notify whenever changed
+        break;
+      }
+    }
   }
 
   return notifyRequired;
index 6884eb9..9a95e27 100644 (file)
@@ -151,7 +151,7 @@ protected:
   ConditionType mConditionType;                 ///< The ConditionType
   RawArgumentContainer mArguments;              ///< The arguments.
   bool mValid;                                  ///< Whether this property notification is currently valid or not.
-  char mNotifyValidity[2];                      ///< Whether to notify on invalid and/or valid
+  NotifyMode mNotifyMode;                       ///< Whether to notify on invalid and/or valid
   ConditionFunction mConditionFunction;         ///< The Condition Function pointer to be evaluated.
 };