e2fsck: optimize away repeated calls to gettext()

Optimize _("getting next inode from scan") so it is not called for
each initialized inode in the file system, and make a similar
optimization in pass 2 for each directory block.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2019-12-13 23:30:53 -05:00
parent 1f0f27059a
commit c4e7324243
2 changed files with 6 additions and 2 deletions

View File

@ -1171,6 +1171,7 @@ void e2fsck_pass1(e2fsck_t ctx)
struct scan_callback_struct scan_struct;
struct ext2_super_block *sb = ctx->fs->super;
const char *old_op;
const char *eop_next_inode = _("getting next inode from scan");
int imagic_fs, extent_fs, inlinedata_fs, casefold_fs;
int low_dtime_check = 1;
unsigned int inode_size = EXT2_INODE_SIZE(fs->super);
@ -1363,7 +1364,7 @@ void e2fsck_pass1(e2fsck_t ctx)
if (e2fsck_mmp_update(fs))
fatal_error(ctx, 0);
}
old_op = ehandler_operation(_("getting next inode from scan"));
old_op = ehandler_operation(eop_next_inode);
pctx.errcode = ext2fs_get_next_inode_full(scan, &ino,
inode, inode_size);
if (ino > ino_threshold)

View File

@ -934,6 +934,7 @@ static int check_dir_block(ext2_filsys fs,
int encrypted = 0;
size_t max_block_size;
int hash_flags = 0;
static char *eop_read_dirblock = NULL;
cd = (struct check_dir_struct *) priv_data;
ibuf = buf = cd->buf;
@ -1004,7 +1005,9 @@ static int check_dir_block(ext2_filsys fs,
db->blockcnt, ino);
#endif
ehandler_operation(_("reading directory block"));
if (!eop_read_dirblock)
eop_read_dirblock = (char *) _("reading directory block");
ehandler_operation(eop_read_dirblock);
if (inline_data_size) {
memset(buf, 0, fs->blocksize - inline_data_size);
cd->pctx.errcode = ext2fs_inline_data_get(fs, ino, 0, buf, 0);