wingo pushed a commit to branch main
in repository guile.
commit f74565defdf7313abad683d3634e94b6efaa7cfe
Author: Andy Wingo <[email protected]>
AuthorDate: Wed May 24 09:17:41 2023 +0200
pretty-print: Use string-concatenate-reverse
* module/ice-9/pretty-print.scm (generic-write): Use
string-concatenate-reverse instead of locally-defined
reverse-string-append.
(reverse-string-append): Remove.
---
module/ice-9/pretty-print.scm | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/module/ice-9/pretty-print.scm b/module/ice-9/pretty-print.scm
index f90e15d38..577545315 100644
--- a/module/ice-9/pretty-print.scm
+++ b/module/ice-9/pretty-print.scm
@@ -1,7 +1,7 @@
;;;; -*- coding: utf-8; mode: scheme -*-
;;;;
;;;; Copyright (C) 2001, 2004, 2006, 2009, 2010,
-;;;; 2012, 2013, 2014 Free Software Foundation, Inc.
+;;;; 2012, 2013, 2014, 2023 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -102,7 +102,7 @@
(set! left (- left (string-length str)))
(> left 0)))
(if (> left 0) ; all can be printed on one line
- (out (reverse-string-append result) col)
+ (out (string-concatenate-reverse result) col)
(if (pair? obj)
(pp-pair obj col extra)
(pp-list (vector->list obj) (out "#" col) extra pp-expr))))
@@ -251,25 +251,6 @@
;; Return `unspecified'
(if #f #f))
-; (reverse-string-append l) = (apply string-append (reverse l))
-
-(define (reverse-string-append l)
-
- (define (rev-string-append l i)
- (if (pair? l)
- (let* ((str (car l))
- (len (string-length str))
- (result (rev-string-append (cdr l) (+ i len))))
- (let loop ((j 0) (k (- (- (string-length result) i) len)))
- (if (< j len)
- (begin
- (string-set! result k (string-ref str j))
- (loop (+ j 1) (+ k 1)))
- result)))
- (make-string i)))
-
- (rev-string-append l 0))
-
(define* (pretty-print obj #:optional port*
#:key
(port (or port* (current-output-port)))