src/show: remove dead offset check code
PATCH 1/1 src/show: remove dead offset check code
At first the offset will always be 0. So the check of offset ? ", " : "" is useless.
Signed-off-by Hangbin Liu <[email protected]>
--- src/show.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/show.c +1 -1
@@ -141,7 +141,7 @@ static size_t pretty_time(char *buf, const size_t len, unsigned long long left) seconds = left %60 ;if (years) - offset +=snprintf (buf + offset, len - offset,"%s%llu " TERMINAL_FG_CYAN "year%s" TERMINAL_RESET , offset ?", " :"" , years, years ==1 ?"" :"s" ); + offset =snprintf (buf, len,"%llu " TERMINAL_FG_CYAN "year%s" TERMINAL_RESET , years, years ==1 ?"" :"s" );if (days) offset +=snprintf (buf + offset, len - offset,"%s%llu " TERMINAL_FG_CYAN "day%s" TERMINAL_RESET , offset ?", " :"" , days, days ==1 ?"" :"s" );if (hours)
Signature · 1 line
2.26.3
The compiler will optimize this out, right? In which case, I like the consistency, in case lines are ever reordered or copy and pasted.
Quoted 2 lines · Jason A. Donenfeld
The compiler will optimize this out, right? In which case, I like the consistency, in case lines are ever reordered or copy and pasted.
Not sure if compiler will optimize. I just got the complain when do covscan checking. I'm OK to keep the format.
Thanks
Hangbin
Looks like the compiler optimizes it:
https://data.zx2c4.com/the-compiler-optimizes-the-first-addition.png