Subject: bug#61305: [PATCH 2/2] ast: Rewrite ast->string using string-join.

From: Arun Isaac <[email-masked]>
Date: Mon, 6 Feb 2023 00:03:09 +0000

* src/guile/skribilo/ast.scm (ast->string): Rewrite using string-join.
---
 src/guile/skribilo/ast.scm | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm
index 4a39ebf..003619f 100644
--- a/src/guile/skribilo/ast.scm
+++ b/src/guile/skribilo/ast.scm
@@ -3,6 +3,7 @@
 ;;; Copyright 2003, 2004, 2009  Erick Gallesio - I3S-CNRS/ESSI <[email-masked]>
 ;;; Copyright 2003, 2004  Manuel Serrano
 ;;; Copyright 2005, 2006, 2007, 2012, 2013, 2015, 2018  Ludovic Courtès <[email-masked]>
+;;; Copyright 2023 Arun Isaac <[email-masked]>
 ;;;
 ;;;
 ;;; This file is part of Skribilo.
@@ -206,16 +207,7 @@
 (define-method (ast->string (ast <number>))  (number->string ast))
 
 (define-method (ast->string (ast <pair>))
-  (let ((out (open-output-string)))
-    (let Loop ((lst ast))
-      (cond
-	((null? lst)
-	   (get-output-string out))
-	(else
-	   (display (ast->string (car lst)) out)
-	   (unless (null? (cdr lst))
-	     (display #\space out))
-	   (Loop (cdr lst)))))))
+  (string-join (map ast->string ast)))

 
-- 
2.38.1