Skip to content

Commit

Permalink
Improve shortcut performance when comparing two boolean expressions
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dennis-tseng99 committed Jul 3, 2024
1 parent 0287c6b commit 9d90fec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sbat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9d90fec

Please sign in to comment.