From 7fef3c0d7cdad433fbf614ad4b5c30b7f99814c8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 22 Apr 2020 06:42:32 -0700 Subject: parser: batched read operation for speed. As a result of this change, the startup time is reduced. The command txr -e '(compile-toplevel nil)' shows a 54% speedup: around 110 milliseconds down from around 170. Programs that read large amounts of TXR Lisp data will benefit. * parser.l (YY_INPUT): Use new get_bytes function instead of get_byte to read a buffer at a time. * stream.c (get_bytes): New function. * stream.h (get_bytes): Declared. --- stream.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'stream.c') diff --git a/stream.c b/stream.c index 7120fd78..d264da16 100644 --- a/stream.c +++ b/stream.c @@ -2972,6 +2972,14 @@ val get_byte(val stream_in) return ops->get_byte(stream); } +val get_bytes(val self, val stream_in, mem_t *ptr, ucnum len) +{ + val stream = default_arg(stream_in, std_input); + struct strm_ops *ops = coerce(struct strm_ops *, + cobj_ops(self, stream, stream_s)); + return unum(ops->fill_buf(stream, ptr, len, 0)); +} + val unget_char(val ch, val stream_in) { val self = lit("unget-char"); -- cgit v1.2.3