Optimize `scm_read_string'.
authorLudovic Courtès <ludo@gnu.org>
Sun, 6 May 2012 22:32:01 +0000 (00:32 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 6 May 2012 22:32:01 +0000 (00:32 +0200)
commitff4d3672757fec3c8509e26bc60abf95f9e8f51a
tree48c928690b6d8e7b68cf0316c998b96de24c4d67
parent5bbd632fc36b14f59d51e4ba2d8e189fd3cc0f76
Optimize `scm_read_string'.

According to the new benchmarks, this leads a 5% speed improvement when
reading small strings, and a 27% improvement when reading large strings.

* libguile/read.c (READER_STRING_BUFFER_SIZE): Change to 128; update
  comment to mention codepoints.
  (scm_read_string): Make `str' a list of strings, instead of a string.
  Store characters read in buffer `c_str'.  Cons to STR when C_STR is
  full, and concatenate/reverse at the end.

* benchmark-suite/benchmarks/read.bm (small, large): New variables.
  Set %DEFAULT-PORT-ENCODING to "UTF-8".
  ("read")["small strings", "large strings"]: New benchmarks.
benchmark-suite/benchmarks/read.bm
libguile/read.c