summaryrefslogtreecommitdiff
path: root/libguile/rdelim.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-01-26 22:59:45 +0100
committerLudovic Courtès <ludo@gnu.org>2011-01-26 23:03:17 +0100
commite578faea202a4e6eeb32e81e489b59119a2e02a0 (patch)
treed474b09fbbb3a3d79adcc75bc413e1b1a2ad9682 /libguile/rdelim.c
parent2183d66e134a5512b5b4993cb5255c1c1308dc47 (diff)
downloadguile-e578faea202a4e6eeb32e81e489b59119a2e02a0.tar.gz
Tweak `read-line'.
* libguile/rdelim.c (LINE_BUFFER_SIZE): Set to 1 KiB instead of 4 KiB. (scm_read_line): Initialize STRING to #f so we actually use the fast path.
Diffstat (limited to 'libguile/rdelim.c')
-rw-r--r--libguile/rdelim.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libguile/rdelim.c b/libguile/rdelim.c
index 0fa0b8f61..760aa47ee 100644
--- a/libguile/rdelim.c
+++ b/libguile/rdelim.c
@@ -122,7 +122,7 @@ SCM_DEFINE (scm_read_line, "%read-line", 0, 1, 0,
{
/* Threshold under which the only allocation performed is that of the
resulting string and pair. */
-#define LINE_BUFFER_SIZE 1024
+#define LINE_BUFFER_SIZE 256
SCM line, strings, result;
scm_t_wchar buf[LINE_BUFFER_SIZE], delim;
@@ -135,11 +135,11 @@ SCM_DEFINE (scm_read_line, "%read-line", 0, 1, 0,
index = 0;
delim = 0;
- strings = SCM_EOL;
+ strings = SCM_BOOL_F;
do
{
- if (index >= sizeof (buf))
+ if (SCM_UNLIKELY (index >= sizeof (buf)))
{
/* The line is getting longer than BUF so store its current
contents in STRINGS. */
@@ -164,7 +164,8 @@ SCM_DEFINE (scm_read_line, "%read-line", 0, 1, 0,
}
while (delim == 0);
- if (scm_is_false (strings))
+ if (SCM_LIKELY (scm_is_false (strings)))
+ /* The fast path. */
line = scm_from_utf32_stringn (buf, index);
else
{