From c4e7324243f4a2104ecccc211f600b9369a96b49 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 13 Dec 2019 23:30:53 -0500 Subject: [PATCH] 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 --- e2fsck/pass1.c | 3 ++- e2fsck/pass2.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index b1469088..c9e8bf82 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -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) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 8b40e93d..06f09549 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -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);