From: Matthew Fernandez Date: Mon, 25 May 2020 18:25:39 +0000 (-0700) Subject: remove MEMSET macro X-Git-Tag: 2.44.1~49^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=235de12f50af73ce36e2512b6283f45fbba0a18c;p=graphviz remove MEMSET macro This macro stepped the target pointer forwards, but the only place in which it was used subsequently stepped the pointer backwards. The manual unrolling of short lengths in the macro is something modern compilers and/or CPUs are capable of if the length is predictable statically or dynamically, respectively. --- diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index d3b332903..7ebb4acce 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -745,17 +745,6 @@ extern "C" { case 2 : *to++ = *fr++; \ case 1 : *to++ = *fr++; \ } -#define MEMSET(s,c,n) \ - switch(n) \ - { default : memset((void*)s,(int)c,n); s += n; break; \ - case 7 : *s++ = c; \ - case 6 : *s++ = c; \ - case 5 : *s++ = c; \ - case 4 : *s++ = c; \ - case 3 : *s++ = c; \ - case 2 : *s++ = c; \ - case 1 : *s++ = c; \ - } extern Sfextern_t _Sfextern; extern Sftab_t _Sftable; diff --git a/lib/sfio/sfnputc.c b/lib/sfio/sfnputc.c index fb136040e..9e8247055 100644 --- a/lib/sfio/sfnputc.c +++ b/lib/sfio/sfnputc.c @@ -12,6 +12,7 @@ *************************************************************************/ #include "sfhdr.h" +#include /* Write out a character n times ** @@ -45,8 +46,7 @@ ssize_t sfnputc(reg Sfio_t * f, reg int c, reg size_t n) } if ((size_t) p > n) p = n; - MEMSET(ps, c, p); - ps -= p; + memset(ps, c, p); w = n; if (ps == f->next) { /* simple sfwrite */