bc: shrink s() in library again
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 10:27:09 +0000 (11:27 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 10:27:09 +0000 (11:27 +0100)
function                                             old     new   delta
bc_lib                                              1596    1586     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10)             Total: -10 bytes
   text    data     bss     dec     hex filename
 980152     485    7296  987933   f131d busybox_old
 980142     485    7296  987923   f1313 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c

index f0c323d93ce8ac1dd7c610c0052a22c8bef2d106..547af8eaf2ebe6f869cb4d9721529d52d84858de 100644 (file)
@@ -7213,16 +7213,13 @@ static const char bc_lib[] ALIGN1 = {
 "\n"           "return(r/1)"
 "\n"   "}"
 "\n"   "define s(x){"
-"\n"           "auto b,s,r,n,a,q,i"
+"\n"           "auto b,s,r,a,q,i"
+"\n"           "if(x<0)return(-s(-x))"
 "\n"           "b=ibase"
 "\n"           "ibase=A"
 "\n"           "s=scale"
 "\n"           "scale=1.1*s+2"
 "\n"           "a=a(1)"
-"\n"           "if(x<0){"
-"\n"                   "n=1"
-"\n"                   "x=-x"
-"\n"           "}"
 "\n"           "scale=0"
 "\n"           "q=(x/a+2)/4"
 "\n"           "x-=4*q*a"
@@ -7236,7 +7233,6 @@ static const char bc_lib[] ALIGN1 = {
 "\n"           "}"
 "\n"           "scale=s"
 "\n"           "ibase=b"
-"\n"           "if(n)r=-r"
 "\n"           "return(r/1)"
 "\n"   "}"
 "\n"   "define c(x){"