From 9d90fec8e71a6ee10be75681d63242b56b027c38 Mon Sep 17 00:00:00 2001 From: Dennis Tseng Date: Wed, 3 Jul 2024 13:15:58 +0800 Subject: [PATCH] Improve shortcut performance when comparing two boolean expressions In original sbat.c: ... else if (preserve_sbat_uefi_variable(sbat, sbatsize, attributes, sbat_var_candidate) && !reset_sbat) { ... The time omplexity of preserve_sbat_uefi_variable() is higher than reset_sbat. Maybe we could swap both of them to calculate reset_sbat first. Such that the shortcut performance can be improved. Signed-off-by: Dennis Tseng --- sbat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbat.c b/sbat.c index 06956122d..9056858c8 100644 --- a/sbat.c +++ b/sbat.c @@ -537,9 +537,9 @@ set_sbat_uefi_variable(char *sbat_var_automatic, char *sbat_var_latest) */ if (EFI_ERROR(efi_status)) { dprint(L"SBAT read failed %r\n", efi_status); - } else if (preserve_sbat_uefi_variable(sbat, sbatsize, attributes, - sbat_var_candidate) && - !reset_sbat) { + } else if (!reset_sbat && + preserve_sbat_uefi_variable(sbat, sbatsize, attributes, + sbat_var_candidate)) { dprint(L"preserving %s variable it is %d bytes, attributes are 0x%08x\n", SBAT_VAR_NAME, sbatsize, attributes); FreePool(sbat);