Optimize `peek-char'.
authorLudovic Courtès <ludo@gnu.org>
Wed, 15 Sep 2010 16:38:57 +0000 (18:38 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 15 Sep 2010 16:38:57 +0000 (18:38 +0200)
commitfd5eec2b6e113f6d13028215a738417607432a2d
treef87058b9bb6f5d2b4b516763e26c663b7e659f9a
parente9c3018cec8ed236a375c59aed55e66e47671022
Optimize `peek-char'.

This makes `peek-char' 40x faster on a port whose encoding is
faster on a UTF-8 port containing multi-byte codepoints.

The `xml->sxml' procedure is 4x faster on a 2.7 MiB XML file.

* libguile/ports.c (get_codepoint): New procedure, moved here from
  `scm_getc', with the additional BUF and LEN parameters.
  (scm_getc): Use it.
  (scm_peek_char): Use it instead of the `scm_getc'/`scm_ungetc'
  sequence.

* test-suite/tests/ports.test ("string ports")["peek-char [latin-1]",
  "peek-char [utf-8]"]: New tests.

* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add
  `benchmarks/ports.bm'.

* benchmark-suite/benchmarks/ports.bm: New file.
benchmark-suite/Makefile.am
benchmark-suite/benchmarks/ports.bm [new file with mode: 0644]
libguile/ports.c
test-suite/tests/ports.test