[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/08: pretty-print: Use string-concatenate-reverse
From: |
Andy Wingo |
Subject: |
[Guile-commits] 01/08: pretty-print: Use string-concatenate-reverse |
Date: |
Mon, 29 May 2023 04:03:37 -0400 (EDT) |
wingo pushed a commit to branch wip-custom-ports
in repository guile.
commit 3d157a49ac4e438d149350749b63cab0edd574fe
Author: Andy Wingo <wingo@pobox.com>
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)))
- [Guile-commits] branch wip-custom-ports created (now 9df5a8dfb), Andy Wingo, 2023/05/29
- [Guile-commits] 03/08: pretty-print: inline some handling of read macros, Andy Wingo, 2023/05/29
- [Guile-commits] 04/08: Add "custom ports", Andy Wingo, 2023/05/29
- [Guile-commits] 06/08: Use custom binary output ports for make-chunked-output-port, Andy Wingo, 2023/05/29
- [Guile-commits] 01/08: pretty-print: Use string-concatenate-reverse,
Andy Wingo <=
- [Guile-commits] 02/08: pretty-print: inline genwrite:newline-str, Andy Wingo, 2023/05/29
- [Guile-commits] 05/08: Rewrite custom binary ports in Scheme, in terms of custom ports, Andy Wingo, 2023/05/29
- [Guile-commits] 08/08: Rewrite soft ports in Scheme, Andy Wingo, 2023/05/29
- [Guile-commits] 07/08: Implement R6RS custom textual ports, Andy Wingo, 2023/05/29