From 24d56456763194702b29a565141d0c32d8933d3f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 27 Jan 2023 14:26:24 +0000 Subject: util/nvmutil: optimise cmd_swap() On many Lenovo GbE regions (in factory firmware), part 0 is invalid but part 1 is valid. This change means part 1 is checked first. If part 1 is valid, part 0 won't be checked at all (due to how most C compilers optimise). Most people are just going to extract the factory GbE file, modify it and re-insert it into the ROM image, so this causes a nice speedup. --- util/nvmutil/nvmutil.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'util') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index e2dafec7..5edb9d48 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -351,12 +351,7 @@ cmd_brick(void) void cmd_swap(void) { - int part0, part1; - - part0 = validChecksum(0); - part1 = validChecksum(1); - - if (part0 || part1) { + if (validChecksum(1) || validChecksum(0)) { gbe[0] ^= gbe[1]; gbe[1] ^= gbe[0]; gbe[0] ^= gbe[1]; -- cgit v1.2.1