]> granicus.if.org Git - graphviz/commitdiff
swap Strcmp calls for strcmp
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 28 Feb 2021 06:03:43 +0000 (22:03 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Mar 2021 16:32:45 +0000 (08:32 -0800)
Strcmp optimized strcmp by unrolling the first iteration of a byte comparison
loop. This is no longer an optimization. In modern compilers/libc, (1) strcmp is
generally no longer a byte-by-byte comparison loop and (2) the compiler knows
strcmp as a built-in and can do this kind of unrolling itself. As a result, the
compiler actually has to do *more* work to reverse Strcmp back into strcmp and
thus determine it can use, e.g., SIMD optimizations.

This is essentially the next step of f5a326cb061866bb3beaa33c3e5169efe7fc134d.

cmd/lefty/aix_mods/exec.c
cmd/lefty/aix_mods/tbl.c
cmd/lefty/ws/gtk/garray.c
cmd/lefty/ws/gtk/gcanvas.c
cmd/lefty/ws/gtk/gquery.c

index 0f3fda1265b0385b2b8fb509cf37b43306e82a12..cad42210d0c4e522f1cd3ccf461f2c515eee5979 100644 (file)
@@ -836,7 +836,7 @@ static int orderop(Tobj v1o, Ctype_t op, Tobj v2o)
     }
     t1 = Tgettype(v1o), t2 = Tgettype(v2o);
     if (t1 == T_STRING && t2 == T_STRING) {
-       r = Strcmp(Tgetstring(v1o), Tgetstring(v2o));
+       r = strcmp(Tgetstring(v1o), Tgetstring(v2o));
     } else if (t1 == T_INTEGER && t2 == T_INTEGER) {
        i1 = Tgetinteger(v1o), i2 = Tgetinteger(v2o);
        r = (i1 == i2) ? 0 : ((i1 < i2) ? -1 : 1);
index 341bf7bcde62b21ed84881a94a8586ee5fe0dc40..5b99e0a82025a35b2465892e3b8bfd5fe45c5e40 100644 (file)
@@ -24,7 +24,7 @@ Tobj Ttrue, Tfalse;
 #define ISEQRK(rk, ko) \
     (T_ISNUMBER (ko) && Tgetnumber (ko) == (rk))
 #define ISEQSK(sk, ko) \
-    (T_ISSTRING (ko)  && Strcmp (((Tstring_t *) (ko))->s, (sk)) == 0)
+    (T_ISSTRING (ko)  && strcmp (((Tstring_t *) (ko))->s, (sk)) == 0)
 
 #define GETIKINDEX(tp, ik) (unsigned long) ik  % tp->ln
 #define GETRKINDEX(tp, rk) (unsigned long) rk  % tp->ln
index 2eb2a25e185e86bcfd63b210b4ce64d889083ea8..fba5ee4b65c1e82cf9c0dd7d097734b17aff9e71 100644 (file)
@@ -38,9 +38,9 @@ int GAcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
        case G_ATTRBORDERWIDTH:
            break;
        case G_ATTRMODE:
-           if (Strcmp("horizontal", attrp[ai].u.t) == 0) {
+           if (strcmp("horizontal", attrp[ai].u.t) == 0) {
                WAU->mode = G_AWHARRAY;
-           } else if (Strcmp("vertical", attrp[ai].u.t) == 0) {
+           } else if (strcmp("vertical", attrp[ai].u.t) == 0) {
                WAU->mode = G_AWVARRAY;
            } else {
                Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
@@ -48,9 +48,9 @@ int GAcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
            }
            break;
        case G_ATTRLAYOUT:
-           if (Strcmp("on", attrp[ai].u.t) == 0)
+           if (strcmp("on", attrp[ai].u.t) == 0)
                Gawsetmode(widget, FALSE);
-           else if (Strcmp("off", attrp[ai].u.t) == 0)
+           else if (strcmp("off", attrp[ai].u.t) == 0)
                Gawsetmode(widget, TRUE);
            else {
                Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
@@ -124,9 +124,9 @@ int GAsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
            Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
            return -1;
        case G_ATTRLAYOUT:
-           if (Strcmp("on", attrp[ai].u.t) == 0)
+           if (strcmp("on", attrp[ai].u.t) == 0)
                Gawsetmode(widget, FALSE);
-           else if (Strcmp("off", attrp[ai].u.t) == 0)
+           else if (strcmp("off", attrp[ai].u.t) == 0)
                Gawsetmode(widget, TRUE);
            else {
                Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
index 48e33e63201db2d74d081904ad0368c76f592b16..57f0b7516adba995f5904a56b1650bc193a1a7bd 100644 (file)
@@ -107,7 +107,7 @@ int GCcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
            break;
 #ifdef FEATURE_GMAP
        case G_ATTRMODE:
-           if (Strcmp("gmap", attrp[ai].u.t) == 0) {
+           if (strcmp("gmap", attrp[ai].u.t) == 0) {
                gmapmode = TRUE;
            } else {
                Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
@@ -211,7 +211,7 @@ int GCcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
     for (ai = 0; ai < attrn; ai++) {
        switch (attrp[ai].id) {
        case G_ATTRCURSOR:
-           if (Strcmp(attrp[ai].u.t, "default") == 0) {
+           if (strcmp(attrp[ai].u.t, "default") == 0) {
                curcursori = -1;
            }
            break;
@@ -269,7 +269,7 @@ int GCsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
        case G_ATTRBORDERWIDTH:
            break;
        case G_ATTRCURSOR:
-           if (Strcmp(attrp[ai].u.t, "watch") == 0) {
+           if (strcmp(attrp[ai].u.t, "watch") == 0) {
                gdk_window_set_cursor(widget->w->window,
                                      gdk_cursor_new(GDK_WATCH));
            } else {
@@ -651,7 +651,7 @@ static GdkFont *findfont(char *name, int size)
 
     sprintf(&Gbufp[0], name, size);
     for (fi = 0; fi < Gfontn; fi++)
-       if (Strcmp(&Gbufp[0], Gfontp[fi].name) == 0)
+       if (strcmp(&Gbufp[0], Gfontp[fi].name) == 0)
            return Gfontp[fi].font;
 
     if (!(font = gdk_font_load(&Gbufp[0]))) {
index b21bc27054ba29c079cca9332f5776761a13f434..6116c1c69823f931925839f39484cce5325576df 100644 (file)
@@ -29,11 +29,11 @@ int GQcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
     for (ai = 0; ai < attrn; ai++) {
        switch (attrp[ai].id) {
        case G_ATTRMODE:
-           if (Strcmp("string", attrp[ai].u.t) == 0)
+           if (strcmp("string", attrp[ai].u.t) == 0)
                WQU->mode = G_QWSTRING;
-           else if (Strcmp("file", attrp[ai].u.t) == 0)
+           else if (strcmp("file", attrp[ai].u.t) == 0)
                WQU->mode = G_QWFILE;
-           else if (Strcmp("choice", attrp[ai].u.t) == 0)
+           else if (strcmp("choice", attrp[ai].u.t) == 0)
                WQU->mode = G_QWCHOICE;
            else {
                Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);