[edk2] [Patch] BaseTools: Remove the redundant if statement

Yonghong Zhu posted 1 patch 17 weeks ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/Common/Expression.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

[edk2] [Patch] BaseTools: Remove the redundant if statement

Posted by Yonghong Zhu 17 weeks ago
after analysis the BuildOptionValue function, we found the if statement
IsFieldValueAnArray is redundant because ValueExpressionEx will handle
it.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/Common/Expression.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index ccc7368..0091e47 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -15,11 +15,11 @@
 from __future__ import print_function
 from __future__ import absolute_import
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
-from .Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue
 import Common.EdkLogger as EdkLogger
 import copy
 from Common.DataType import *
 import sys
 
@@ -136,15 +136,15 @@ def BuildOptionValue(PcdValue, GuidDict):
         InputValue = PcdValue
     elif PcdValue.startswith('L'):
         InputValue = 'L"' + PcdValue[1:] + '"'
     else:
         InputValue = PcdValue
-    if IsFieldValueAnArray(InputValue):
-        try:
-            PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True)
-        except:
-            pass
+    try:
+        PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True)
+    except:
+        pass
+
     return PcdValue
 
 ## ReplaceExprMacro
 #
 def ReplaceExprMacro(String, Macros, ExceptionList = None):
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Re: [edk2] [Patch] BaseTools: Remove the redundant if statement

Posted by Gao, Liming 17 weeks ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Zhu, Yonghong
> Sent: Thursday, August 9, 2018 11:49 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [Patch] BaseTools: Remove the redundant if statement
> 
> after analysis the BuildOptionValue function, we found the if statement
> IsFieldValueAnArray is redundant because ValueExpressionEx will handle
> it.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
>  BaseTools/Source/Python/Common/Expression.py | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
> index ccc7368..0091e47 100644
> --- a/BaseTools/Source/Python/Common/Expression.py
> +++ b/BaseTools/Source/Python/Common/Expression.py
> @@ -15,11 +15,11 @@
>  from __future__ import print_function
>  from __future__ import absolute_import
>  from Common.GlobalData import *
>  from CommonDataClass.Exceptions import BadExpression
>  from CommonDataClass.Exceptions import WrnExpression
> -from .Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
> +from .Misc import GuidStringToGuidStructureString, ParseFieldValue
>  import Common.EdkLogger as EdkLogger
>  import copy
>  from Common.DataType import *
>  import sys
> 
> @@ -136,15 +136,15 @@ def BuildOptionValue(PcdValue, GuidDict):
>          InputValue = PcdValue
>      elif PcdValue.startswith('L'):
>          InputValue = 'L"' + PcdValue[1:] + '"'
>      else:
>          InputValue = PcdValue
> -    if IsFieldValueAnArray(InputValue):
> -        try:
> -            PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True)
> -        except:
> -            pass
> +    try:
> +        PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True)
> +    except:
> +        pass
> +
>      return PcdValue
> 
>  ## ReplaceExprMacro
>  #
>  def ReplaceExprMacro(String, Macros, ExceptionList = None):
> --
> 2.6.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel