ash: get rid of separate mail_var_path_changed flag variable

We can just clear mailtime_hash to zero and have the same effect.

function                                             old     new   delta
changemail                                             8      11      +3
mail_var_path_changed                                  1       -      -1
cmdloop                                              398     382     -16
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 3/-17)             Total: -14 bytes
   text	   data	    bss	    dec	    hex	filename
1054786	    559	   5020	1060365	 102e0d	busybox_old
1054773	    559	   5020	1060352	 102e00	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
master
Denys Vlasenko 2023-04-03 15:01:00 +02:00
parent 7ababc3e3c
commit 94780e3e8e
1 changed files with 9 additions and 10 deletions
shell

View File

@ -2110,10 +2110,7 @@ change_lc_ctype(const char *value)
}
#endif
#if ENABLE_ASH_MAIL
static void chkmail(void);
static void changemail(const char *var_value) FAST_FUNC;
#else
# define chkmail() ((void)0)
#endif
static void changepath(const char *) FAST_FUNC;
#if ENABLE_ASH_RANDOM_SUPPORT
@ -11258,13 +11255,12 @@ setinputstring(char *string)
#if ENABLE_ASH_MAIL
/* Hash of mtimes of mailboxes */
/* Cleared to 0 if MAIL or MAILPATH is changed */
static unsigned mailtime_hash;
/* Set if MAIL or MAILPATH is changed. */
static smallint mail_var_path_changed;
/*
* Print appropriate message(s) if mail has arrived.
* If mail_var_path_changed is set,
* If mailtime_hash is zero,
* then the value of MAIL has changed,
* so we just update the hash value.
*/
@ -11303,21 +11299,24 @@ chkmail(void)
/* Very simplistic "hash": just a sum of all mtimes */
new_hash += (unsigned)statb.st_mtime;
}
if (!mail_var_path_changed && mailtime_hash != new_hash) {
if (mailtime_hash != new_hash) {
if (mailtime_hash != 0)
out2str("you have mail\n");
mailtime_hash = new_hash;
}
mailtime_hash = new_hash;
mail_var_path_changed = 0;
popstackmark(&smark);
}
static void FAST_FUNC
changemail(const char *val UNUSED_PARAM)
{
mail_var_path_changed = 1;
mailtime_hash = 0;
}
#else
# define chkmail() ((void)0)
#endif /* ASH_MAIL */