]> granicus.if.org Git - graphviz/commitdiff
check internal map for IDs prior to creating one from a string
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 1 Aug 2020 19:19:27 +0000 (12:19 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 8 Aug 2020 01:48:49 +0000 (18:48 -0700)
This has no effect currently because the case that preceded this check was for
non-local names, that are not inserted into the internal map anyway. However, an
upcoming change will alter this behavior, so we want to make sure that if a name
already has a known ID it is found first. Related to #1767.

lib/cgraph/id.c

index 694220ef39d41ff7c085892bd55436e42ec3c3c2..93dc829c08b6b7b5d0d3fe3476155ebf4c270d6a 100644 (file)
@@ -98,13 +98,6 @@ int agmapnametoid(Agraph_t * g, int objtype, char *str,
 {
     int rv;
 
-    if (str && (str[0] != LOCALNAMEPREFIX)) {
-       rv = AGDISC(g, id)->map(AGCLOS(g, id), objtype, str, result,
-                               createflag);
-       if (rv)
-           return rv;
-    }
-
     /* either an internal ID, or disc. can't map strings */
     if (str) {
        rv = aginternalmaplookup(g, objtype, str, result);
@@ -113,6 +106,13 @@ int agmapnametoid(Agraph_t * g, int objtype, char *str,
     } else
        rv = 0;
 
+    if (str && (str[0] != LOCALNAMEPREFIX)) {
+       rv = AGDISC(g, id)->map(AGCLOS(g, id), objtype, str, result,
+                               createflag);
+       if (rv)
+           return rv;
+    }
+
     if (createflag) {
        /* get a new anonymous ID, and store in the internal map */
        rv = AGDISC(g, id)->map(AGCLOS(g, id), objtype, NILstr, result,