From: Matthew Fernandez Date: Thu, 18 Aug 2022 00:42:35 +0000 (-0700) Subject: gvc gvprintpointflist: rewrite for clarity X-Git-Tag: 6.0.1~33^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=babbca7e1bb3eb58274a15f6d6e7c344b9016201;p=graphviz gvc gvprintpointflist: rewrite for clarity The unusual structure of the loop in this function made it appear as if it was intending to cope with e.g. an `n` of 0 but still print the first element of `p`. Surveying the callers of `gvprintpointflist`, we can see it is never used this way. So we can write it simpler and more readably. --- diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index 5ced43c12..7a8c6f9b3 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -597,12 +597,10 @@ void gvprintpointf(GVJ_t * job, pointf p) void gvprintpointflist(GVJ_t * job, pointf *p, int n) { - int i = 0; - - while (true) { - gvprintpointf(job, p[i]); - if (++i >= n) break; - gvwrite(job, " ", 1); - } + const char *separator = ""; + for (int i = 0; i < n; ++i) { + gvputs(job, separator); + gvprintpointf(job, p[i]); + separator = " "; + } } -