mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-22 19:44:10 +02:00
rdelim: Speed up 'read-string' (aka. 'get-string-all'.)
This yields a 20% improvement on the "read-string" benchmark. * module/ice-9/rdelim.scm (read-string): Rewrite as a 'case-lambda', with a tight loop around 'read-char', and without using 'read-string!'. * test-suite/tests/rdelim.test ("read-string")["longer than 100 chars, with limit"]: New test. * benchmark-suite/benchmarks/ports.bm ("rdelim")["read-string"]: New benchmark.
This commit is contained in:
parent
eb6ac6efcd
commit
a41b07a34f
3 changed files with 40 additions and 24 deletions
|
@ -1,7 +1,7 @@
|
|||
;;;; rdelim.test --- Delimited I/O. -*- mode: scheme; coding: utf-8; -*-
|
||||
;;;; Ludovic Courtès <ludo@gnu.org>
|
||||
;;;;
|
||||
;;;; Copyright (C) 2011, 2013 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2011, 2013, 2014 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
|
||||
|
@ -209,7 +209,13 @@
|
|||
(let* ((s (string-concatenate (make-list 20 "hello, world!")))
|
||||
(p (open-input-string s)))
|
||||
(and (string=? (read-string p) s)
|
||||
(string=? (read-string p) "")))))
|
||||
(string=? (read-string p) ""))))
|
||||
|
||||
(pass-if-equal "longer than 100 chars, with limit"
|
||||
"hello, world!"
|
||||
(let* ((s (string-concatenate (make-list 20 "hello, world!")))
|
||||
(p (open-input-string s)))
|
||||
(read-string p 13))))
|
||||
|
||||
(with-test-prefix "read-string!"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue