mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-12-02 22:43:48 +08:00
e2fsck: optimize CPU usage in check_{block,inode}_bitmaps()
The boolean expression (!skip_group || csum_flag) is always true, since if csum_flag is FALSE, skip_group must also be FALSE. Hence, we can just remove the expression from the conditional altogether, thus simplifying the code and making it easier to read/understand. Also, in the case where the bit is set in the bitmap, there's no point repeatedly setting first_free to be ext2fs_block_count(fs->super). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
deae60a087
commit
d2c9c42a0b
@ -372,15 +372,14 @@ redo_counts:
|
||||
ctx->options &= ~E2F_OPT_DISCARD;
|
||||
|
||||
do_counts:
|
||||
if (!bitmap && (!skip_group || csum_flag)) {
|
||||
if (!bitmap) {
|
||||
group_free++;
|
||||
free_blocks++;
|
||||
if (first_free > i)
|
||||
first_free = i;
|
||||
} else {
|
||||
if (i > first_free)
|
||||
e2fsck_discard_blocks(ctx, first_free,
|
||||
(i - first_free));
|
||||
} else if (i > first_free) {
|
||||
e2fsck_discard_blocks(ctx, first_free,
|
||||
(i - first_free));
|
||||
first_free = ext2fs_blocks_count(fs->super);
|
||||
}
|
||||
blocks ++;
|
||||
@ -627,7 +626,7 @@ do_counts:
|
||||
inodes - first_free);
|
||||
first_free = fs->super->s_inodes_per_group + 1;
|
||||
}
|
||||
} else if (!skip_group || csum_flag) {
|
||||
} else {
|
||||
group_free++;
|
||||
free_inodes++;
|
||||
if (first_free > inodes)
|
||||
|
Loading…
Reference in New Issue
Block a user