From d5f07def65fd2348dd7bda008c24c93a195ce19b Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Sun, 23 Dec 2018 13:23:34 +1300 Subject: [PATCH] Small optimisation --- minivhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minivhd.c b/minivhd.c index b9d2e17..250a396 100644 --- a/minivhd.c +++ b/minivhd.c @@ -469,7 +469,6 @@ int vhd_read_sectors(VHDMeta *vhdm, FILE *f, int offset, int nr_sectors, void *b for (s = offset; s <= ls; s++) { curr_blk = s / vhdm->sparse_spb; - sib = s % vhdm->sparse_spb; /* If the data block doesn't yet exist, fill the buffer with zero data */ if (vhdm->sparse_bat_arr[curr_blk] == VHD_SPARSE_BLK) { @@ -479,6 +478,7 @@ int vhd_read_sectors(VHDMeta *vhdm, FILE *f, int offset, int nr_sectors, void *b { if (curr_blk != prev_blk) { + sib = s % vhdm->sparse_spb; uint32_t file_sect_offs = vhdm->sparse_bat_arr[curr_blk] + sbsz + sib; fseeko64(f, (uint64_t)file_sect_offs * VHD_SECTOR_SZ, SEEK_SET); prev_blk = curr_blk;