[edk2-devel] [PATCH EDK2 v2 1/1] BaseTools/GenFfs: Optimazing else if statement

Bob Feng bob.c.feng at intel.com
Mon Dec 21 02:27:44 UTC 2020


Created a PR https://github.com/tianocore/edk2/pull/1250


-----Original Message-----
From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Bob Feng
Sent: Monday, December 21, 2020 10:07 AM
To: devel at edk2.groups.io; xiewenyi2 at huawei.com; gaoliming at byosoft.com.cn; Chen, Christine <yuwei.chen at intel.com>
Cc: songdongkuang at huawei.com
Subject: Re: [edk2-devel] [PATCH EDK2 v2 1/1] BaseTools/GenFfs: Optimazing else if statement

Reviewed-by: Bob Feng <bob.c.feng at intel.com>

-----Original Message-----
From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of wenyi,xie via groups.io
Sent: Tuesday, December 15, 2020 2:31 PM
To: devel at edk2.groups.io; Feng, Bob C <bob.c.feng at intel.com>; gaoliming at byosoft.com.cn; Chen, Christine <yuwei.chen at intel.com>
Cc: songdongkuang at huawei.com; xiewenyi2 at huawei.com
Subject: [edk2-devel] [PATCH EDK2 v2 1/1] BaseTools/GenFfs: Optimazing else if statement

When Alignment < 0x400 is false, the expression of Alignment >= 0x400 is always true. So extract the expression from the else if statement.

Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2 at huawei.com>
---
 BaseTools/Source/C/GenFfs/GenFfs.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
index fcb911f4fc34..949025c33325 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -821,12 +821,11 @@ Returns:
           if (Alignment < 0x400){
             sprintf (AlignmentBuffer, "%d", Alignment);
           }
-          else if (Alignment >= 0x400) {
-            if (Alignment >= 0x100000) {
-              sprintf (AlignmentBuffer, "%dM", Alignment/0x100000);
-            } else {
-              sprintf (AlignmentBuffer, "%dK", Alignment/0x400);
-            }
+          else if (Alignment >= 0x100000) {
+            sprintf (AlignmentBuffer, "%dM", Alignment/0x100000);
+          }
+          else {
+            sprintf (AlignmentBuffer, "%dK", Alignment/0x400);
           }
           Status = StringtoAlignment (AlignmentBuffer, &(InputFileAlign[InputFileNum]));
         }
--
2.20.1.windows.1













-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69291): https://edk2.groups.io/g/devel/message/69291
Mute This Topic: https://groups.io/mt/78971296/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list