]> granicus.if.org Git - graphviz/commitdiff
remove MEMSET macro
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 25 May 2020 18:25:39 +0000 (11:25 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 31 May 2020 02:40:54 +0000 (19:40 -0700)
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.

lib/sfio/sfhdr.h
lib/sfio/sfnputc.c

index d3b33290345bf20712b1b23e05529168eda995c7..7ebb4acce05d00b8b702ef34cdfc6973718819e8 100644 (file)
@@ -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;
index fb136040eca530d97f87b377a54f86e9937995c0..9e824705515721ecdc4ab88c97363664dcb76495 100644 (file)
@@ -12,6 +12,7 @@
  *************************************************************************/
 
 #include       "sfhdr.h"
+#include <string.h>
 
 /*     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 */