]> granicus.if.org Git - graphviz/commitdiff
epsf_emit_body: undo a 'strcmp' micro-optimization
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Mar 2022 22:42:45 +0000 (14:42 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 7 Mar 2022 00:39:56 +0000 (16:39 -0800)
The preceding `%` checks are unnecessary to do separately. Modern compilers can
do this kind of optimization themselves.

lib/common/psusershape.c

index e81840e0d2f60189e9976e35a884c7a7bad28661..116c5f34eef3241d8b28697aa7b16c67aa85727b 100644 (file)
@@ -193,12 +193,8 @@ void epsf_emit_body(GVJ_t *job, usershape_t *us)
     p = us->data;
     while (*p) {
        /* skip %%EOF lines */
-       if ((p[0] == '%') && (p[1] == '%')
-               && (!strncasecmp(&p[2], "EOF", 3)
-               || !strncasecmp(&p[2], "BEGIN", 5)
-               || !strncasecmp(&p[2], "END", 3)
-               || !strncasecmp(&p[2], "TRAILER", 7)
-       )) {
+       if (!strncasecmp(p, "%%EOF", 5) || !strncasecmp(p, "%%BEGIN", 7) ||
+           !strncasecmp(p, "%%END", 5) || !strncasecmp(p, "%%TRAILER", 9)) {
            /* check for *p since last line might not end in '\n' */
            while ((c = *p) && (c != '\r') && (c != '\n')) p++;
            if ((*p == '\r') && (*(p+1) == '\n')) p += 2;