This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AW: [PATCH] Speed-up decimal formatting in *printf().


[ Private mail, so sender omitted... ]

Sergei Organov wrote:
The patch below boosts performance of decimal formatting of
integers by
roughly a factor of 2 on ARM7 CPU without hardware integer
division. In
fact it replaces integer modulo operation with multiply and
subtract,
that hopefully is either faster or roughly the same on all supported
CPUs.
I agree. I've applied the patch, thanks!

I think this patch could need a comment in the code, which explains why there's not simply a modulo.

Good idea. I've added this:
Index: src/output/vfnprintf.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx,v
retrieving revision 1.9
diff -u -5 -p -r1.9 vfnprintf.cxx
--- src/output/vfnprintf.cxx 22 Dec 2006 21:37:00 -0000 1.9
+++ src/output/vfnprintf.cxx 2 Jan 2007 11:53:12 -0000
@@ -553,10 +553,11 @@ number: if ((dprec = pre
break;


case DEC:
/* many numbers are 1 digit */
while (_uquad >= 10) {
+ /* The following is usually faster than using a modulo */
u_quad_t next = _uquad / 10;
*--cp = to_char(_uquad - (next * 10));
_uquad = next;
}
*--cp = to_char(_uquad);
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
Company legal info, address and number: http://www.ecoscentric.com/legal
------["The best things in life aren't things."]------ Opinions==mine



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]