Cleanup the code a bit to make it more readable.
authorGreg Clayton <gclayton@apple.com>
Mon, 22 Jun 2015 17:38:30 +0000 (17:38 +0000)
committerGreg Clayton <gclayton@apple.com>
Mon, 22 Jun 2015 17:38:30 +0000 (17:38 +0000)
Add some if/then to avoid calling a function to get dynamic/synthetic types if we know we aren't going to need to call it.

Avoid calling a function that returns a shared pointer twice: once for testing it and once for assigning it (even though that shared pointer is cached inside the value object), it just makes the code a bit clearer.

llvm-svn: 240299

lldb/source/API/SBValue.cpp

index 112954e..72f30e3 100644 (file)
@@ -150,10 +150,20 @@ public:
             return ValueObjectSP();
         }
 
-        if (value_sp->GetDynamicValue(m_use_dynamic))
-            value_sp = value_sp->GetDynamicValue(m_use_dynamic);
-        if (value_sp->GetSyntheticValue(m_use_synthetic))
-            value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
+        if (m_use_dynamic != eNoDynamicValues)
+        {
+            ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
+            if (dynamic_sp)
+                value_sp = dynamic_sp;
+        }
+
+        if (m_use_synthetic)
+        {
+            ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
+            if (synthetic_sp)
+                value_sp = synthetic_sp;
+        }
+
         if (!value_sp)
             error.SetErrorString("invalid value object");
         if (!m_name.IsEmpty())