[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/18: pretty-print: Use string-concatenate-reverse
From: |
Andy Wingo |
Subject: |
[Guile-commits] 01/18: pretty-print: Use string-concatenate-reverse |
Date: |
Thu, 8 Jun 2023 04:26:41 -0400 (EDT) |
wingo pushed a commit to branch main
in repository guile.
commit f74565defdf7313abad683d3634e94b6efaa7cfe
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 main updated (cd57379b3 -> 02dfb6e77), Andy Wingo, 2023/06/08
- [Guile-commits] 03/18: pretty-print: inline some handling of read macros, Andy Wingo, 2023/06/08
- [Guile-commits] 05/18: Add "custom ports", Andy Wingo, 2023/06/08
- [Guile-commits] 06/18: Rewrite custom binary ports in Scheme, in terms of custom ports, Andy Wingo, 2023/06/08
- [Guile-commits] 08/18: Rewrite soft ports in Scheme, Andy Wingo, 2023/06/08
- [Guile-commits] 04/18: bytevector-slice: optimize trivial case, Andy Wingo, 2023/06/08
- [Guile-commits] 16/18: Load (ice-9 binary-ports) from C in thread-safe way, Andy Wingo, 2023/06/08
- [Guile-commits] 07/18: Use custom binary output ports for make-chunked-output-port, Andy Wingo, 2023/06/08
- [Guile-commits] 13/18: Inline generic-write into pretty-print, Andy Wingo, 2023/06/08
- [Guile-commits] 10/18: Modernize soft ports, Andy Wingo, 2023/06/08
- [Guile-commits] 01/18: pretty-print: Use string-concatenate-reverse,
Andy Wingo <=
- [Guile-commits] 17/18: Deprecate (ice-9 lineio), Andy Wingo, 2023/06/08
- [Guile-commits] 18/18: Fix exn dispatch for exns within pre-unwind handlers, Andy Wingo, 2023/06/08
- [Guile-commits] 09/18: Implement R6RS custom textual ports, Andy Wingo, 2023/06/08
- [Guile-commits] 11/18: Rewrite pretty-print to rely on port-column, abort early, Andy Wingo, 2023/06/08
- [Guile-commits] 14/18: truncated-print: use call-with-truncating-output-string, Andy Wingo, 2023/06/08
- [Guile-commits] 12/18: pretty-print: width arg is never false, Andy Wingo, 2023/06/08
- [Guile-commits] 15/18: Fix allow-newline? in call-with-truncating-output-string, Andy Wingo, 2023/06/08
- [Guile-commits] 02/18: pretty-print: inline genwrite:newline-str, Andy Wingo, 2023/06/08