]> granicus.if.org Git - graphviz/commitdiff
common parse_style: remove static backing buffer for 'ps_xb'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 11 Dec 2022 19:51:31 +0000 (11:51 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 14 Dec 2022 01:05:42 +0000 (17:05 -0800)
There seems little value retaining this when it adds complication and was a
contributing factor in the bug just fixed. This potentially slightly degrades
performance (initial style use results in a heap allocation), but is unlikely to
be measurable and should be regained back if we implement Small String
Optimization on `agxbuf`.

lib/common/emit.c

index ee04cbda332757d5d0906b4eb33c855eb4c94768..b6b8265c446c3aab604fbdc531c5468e6e0f973a 100644 (file)
@@ -3795,7 +3795,6 @@ static token_t style_token(char **s) {
 }
 
 #define FUNLIMIT 64
-static char outbuf[SMALLBUF];
 static agxbuf ps_xb;
 
 /* parse_style:
@@ -3810,16 +3809,10 @@ char **parse_style(char *s)
 {
     static char *parse[FUNLIMIT];
     size_t parse_offsets[sizeof(parse) / sizeof(parse[0])];
-    static bool is_first = true;
     size_t fun = 0;
     bool in_parens = false;
     char *p;
 
-    if (is_first) {
-       agxbinit(&ps_xb, SMALLBUF, outbuf);
-       is_first = false;
-    }
-
     p = s;
     while (true) {
        token_t c = style_token(&p);