perf: join-strings via output port (was O(n^2) string-append)

ober

9b87bd848e8907479d813607010d4311e82e4b9f

diff --git a/lib/jerboa-dns/protocol.ss b/lib/jerboa-dns/protocol.ss
index 5f5ff7d..8f72d58 100644
--- a/lib/jerboa-dns/protocol.ss
+++ b/lib/jerboa-dns/protocol.ss
@@ -170,9 +170,14 @@
 
   (def (join-strings lst sep)
     (if (null? lst) ""
-      (let loop ([rest (cdr lst)] [acc (car lst)])
-        (if (null? rest) acc
-          (loop (cdr rest) (string-append acc sep (car rest)))))))
+      (let ([out (open-output-string)])
+        (display (car lst) out)
+        (let loop ([rest (cdr lst)])
+          (unless (null? rest)
+            (display sep out)
+            (display (car rest) out)
+            (loop (cdr rest))))
+        (get-output-string out))))
 
   (def (dns-domain-length bv offset)
     ;; Total bytes consumed by the domain name (including terminating 0)