public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/Oniguruma: Remove redundant IF statement
@ 2019-10-21  2:13 Zhang, Shenglei
  2019-10-30  7:20 ` [edk2-devel] " Wu, Hao A
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Shenglei @ 2019-10-21  2:13 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Hao A Wu

The if statement is not necessary, so keep it to edk2 style.
And this change has been merged to onigruma.
REF:https://github.com/kkos/oniguruma/pull/158

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 .../Oniguruma/unicode_fold1_key.c              | 18 +++++++-----------
 .../Oniguruma/unicode_fold2_key.c              | 17 ++++++-----------
 .../Oniguruma/unicode_fold3_key.c              | 18 +++++++-----------
 .../Oniguruma/unicode_unfold_key.c             | 17 ++++++-----------
 4 files changed, 26 insertions(+), 44 deletions(-)

diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1_key.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1_key.c
index 7dbd6a5995be..0aa54ee172b2 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1_key.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1_key.c
@@ -2983,17 +2983,13 @@ onigenc_unicode_fold1_key(OnigCodePoint codes[])
       4026
     };
 
-  if (0 == 0)
-    {
-      int key = hash(codes);
-
-      if (key <= MAX_HASH_VALUE)
-        {
-          int index = wordlist[key];
-
-          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds1 + index, 1) == 0)
-            return index;
-        }
+    int key = hash(codes);
+    if (key <= MAX_HASH_VALUE) {
+      int index = wordlist[key];
+      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds1 + index, 1) == 0) {
+        return index;
+      }
     }
+
   return -1;
 }
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2_key.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2_key.c
index 3d93e2417a2c..44f8cb660071 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2_key.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2_key.c
@@ -211,17 +211,12 @@ onigenc_unicode_fold2_key(OnigCodePoint codes[])
       129
     };
 
-  if (0 == 0)
-    {
-      int key = hash(codes);
-
-      if (key <= MAX_HASH_VALUE)
-        {
-          int index = wordlist[key];
-
-          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2) == 0)
-            return index;
-        }
+    int key = hash(codes);
+    if (key <= MAX_HASH_VALUE) {
+      int index = wordlist[key];
+      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2) == 0)
+        return index;
     }
+
   return -1;
 }
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3_key.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3_key.c
index bdd5667c6ae2..b36500b135e6 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3_key.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3_key.c
@@ -121,17 +121,13 @@ onigenc_unicode_fold3_key(OnigCodePoint codes[])
       0
     };
 
-  if (0 == 0)
-    {
-      int key = hash(codes);
-
-      if (key <= MAX_HASH_VALUE)
-        {
-          int index = wordlist[key];
-
-          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds3 + index, 3) == 0)
-            return index;
-        }
+    int key = hash(codes);
+    if (key <= MAX_HASH_VALUE) {
+      int index = wordlist[key];
+      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds3 + index, 3) == 0) {
+        return index;
+      }
     }
+
   return -1;
 }
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfold_key.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfold_key.c
index 10f7889ea372..1f03b21cfe54 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfold_key.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfold_key.c
@@ -3288,17 +3288,12 @@ onigenc_unicode_unfold_key(OnigCodePoint code)
       {0x1e907, 4005, 1}
     };
 
-  if (0 == 0)
-    {
-      int key = hash(&code);
-
-      if (key <= MAX_HASH_VALUE)
-        {
-          OnigCodePoint gcode = wordlist[key].code;
-
-          if (code == gcode && wordlist[key].index >= 0)
-            return &wordlist[key];
-        }
+    int key = hash(&code);
+    if (key <= MAX_HASH_VALUE) {
+      OnigCodePoint gcode = wordlist[key].code;
+      if (code == gcode && wordlist[key].index >= 0) {
+        return &wordlist[key];
+      }
     }
   return 0;
 }
-- 
2.18.0.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg/Oniguruma: Remove redundant IF statement
  2019-10-21  2:13 [PATCH] MdeModulePkg/Oniguruma: Remove redundant IF statement Zhang, Shenglei
@ 2019-10-30  7:20 ` Wu, Hao A
  0 siblings, 0 replies; 2+ messages in thread
From: Wu, Hao A @ 2019-10-30  7:20 UTC (permalink / raw)
  To: devel@edk2.groups.io, Zhang, Shenglei; +Cc: Wang, Jian J

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Monday, October 21, 2019 10:13 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J; Wu, Hao A
> Subject: [edk2-devel] [PATCH] MdeModulePkg/Oniguruma: Remove redundant
> IF statement
> 
> The if statement is not necessary, so keep it to edk2 style.
> And this change has been merged to onigruma.
> REF:https://github.com/kkos/oniguruma/pull/158


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  .../Oniguruma/unicode_fold1_key.c              | 18 +++++++-----------
>  .../Oniguruma/unicode_fold2_key.c              | 17 ++++++-----------
>  .../Oniguruma/unicode_fold3_key.c              | 18 +++++++-----------
>  .../Oniguruma/unicode_unfold_key.c             | 17 ++++++-----------
>  4 files changed, 26 insertions(+), 44 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1
> _key.c
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1
> _key.c
> index 7dbd6a5995be..0aa54ee172b2 100644
> ---
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1
> _key.c
> +++
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold1
> _key.c
> @@ -2983,17 +2983,13 @@ onigenc_unicode_fold1_key(OnigCodePoint
> codes[])
>        4026
>      };
> 
> -  if (0 == 0)
> -    {
> -      int key = hash(codes);
> -
> -      if (key <= MAX_HASH_VALUE)
> -        {
> -          int index = wordlist[key];
> -
> -          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds1 + index, 1)
> == 0)
> -            return index;
> -        }
> +    int key = hash(codes);
> +    if (key <= MAX_HASH_VALUE) {
> +      int index = wordlist[key];
> +      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds1 + index, 1)
> == 0) {
> +        return index;
> +      }
>      }
> +
>    return -1;
>  }
> diff --git
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2
> _key.c
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2
> _key.c
> index 3d93e2417a2c..44f8cb660071 100644
> ---
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2
> _key.c
> +++
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold2
> _key.c
> @@ -211,17 +211,12 @@ onigenc_unicode_fold2_key(OnigCodePoint codes[])
>        129
>      };
> 
> -  if (0 == 0)
> -    {
> -      int key = hash(codes);
> -
> -      if (key <= MAX_HASH_VALUE)
> -        {
> -          int index = wordlist[key];
> -
> -          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2)
> == 0)
> -            return index;
> -        }
> +    int key = hash(codes);
> +    if (key <= MAX_HASH_VALUE) {
> +      int index = wordlist[key];
> +      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2)
> == 0)
> +        return index;
>      }
> +
>    return -1;
>  }
> diff --git
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3
> _key.c
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3
> _key.c
> index bdd5667c6ae2..b36500b135e6 100644
> ---
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3
> _key.c
> +++
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_fold3
> _key.c
> @@ -121,17 +121,13 @@ onigenc_unicode_fold3_key(OnigCodePoint codes[])
>        0
>      };
> 
> -  if (0 == 0)
> -    {
> -      int key = hash(codes);
> -
> -      if (key <= MAX_HASH_VALUE)
> -        {
> -          int index = wordlist[key];
> -
> -          if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds3 + index, 3)
> == 0)
> -            return index;
> -        }
> +    int key = hash(codes);
> +    if (key <= MAX_HASH_VALUE) {
> +      int index = wordlist[key];
> +      if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds3 + index, 3)
> == 0) {
> +        return index;
> +      }
>      }
> +
>    return -1;
>  }
> diff --git
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfol
> d_key.c
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfol
> d_key.c
> index 10f7889ea372..1f03b21cfe54 100644
> ---
> a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfol
> d_key.c
> +++
> b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/unicode_unfol
> d_key.c
> @@ -3288,17 +3288,12 @@ onigenc_unicode_unfold_key(OnigCodePoint code)
>        {0x1e907, 4005, 1}
>      };
> 
> -  if (0 == 0)
> -    {
> -      int key = hash(&code);
> -
> -      if (key <= MAX_HASH_VALUE)
> -        {
> -          OnigCodePoint gcode = wordlist[key].code;
> -
> -          if (code == gcode && wordlist[key].index >= 0)
> -            return &wordlist[key];
> -        }
> +    int key = hash(&code);
> +    if (key <= MAX_HASH_VALUE) {
> +      OnigCodePoint gcode = wordlist[key].code;
> +      if (code == gcode && wordlist[key].index >= 0) {
> +        return &wordlist[key];
> +      }
>      }
>    return 0;
>  }
> --
> 2.18.0.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-30  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-21  2:13 [PATCH] MdeModulePkg/Oniguruma: Remove redundant IF statement Zhang, Shenglei
2019-10-30  7:20 ` [edk2-devel] " Wu, Hao A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox