From 76be37ae450b3e24c2deda9348954b79c2291b03 Mon Sep 17 00:00:00 2001 From: Keith Marshall Date: Sun, 24 Jul 2016 16:35:49 +0100 Subject: [PATCH] Optimize printf() field width accumulation function. --- mingwrt/ChangeLog | 8 ++++++++ mingwrt/mingwex/stdio/pformat.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog index 7347834..6378264 100644 --- a/mingwrt/ChangeLog +++ b/mingwrt/ChangeLog @@ -1,3 +1,11 @@ +2016-07-24 Keith Marshall + + Optimize printf() field width accumulation function. + + * mingwex/stdio/pformat.c (__imul10plus): Omit multiply by ten on + already accumulated zero total; it is unnecessary, since ten times + zero is still zero. + 2016-07-22 Keith Marshall Fix printf() field width parsing regression issue [#2309]. diff --git a/mingwrt/mingwex/stdio/pformat.c b/mingwrt/mingwex/stdio/pformat.c index a40ef02..593e712 100644 --- a/mingwrt/mingwex/stdio/pformat.c +++ b/mingwrt/mingwex/stdio/pformat.c @@ -1758,7 +1758,7 @@ static __pformat_inline__ * able to override an initial PFORMAT_IGNORE (-1) setting). */ int __pformat_imul10plus( int total, int units ) -{ return units + ((total >= 0) ? ((total + (total << 2)) << 1) : 0); } +{ return units + ((total > 0) ? ((total + (total << 2)) << 1) : 0); } static int __pformat_read_arg_index( const char **fmt ) -- 2.11.0