]> git.eshelyaron.com Git - emacs.git/commit
Speed up low-level parts of the reader and refactor
authorMattias EngdegÄrd <mattiase@acm.org>
Sun, 26 May 2024 11:44:32 +0000 (13:44 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 08:00:45 +0000 (10:00 +0200)
commita245f383c27c84ac6af02939435efb8ebc433147
tree74cbc544780848957bcaa096bc6774a599e6bb0d
parentf54e534f0acf52496538552a46f36367c93c783d
Speed up low-level parts of the reader and refactor

Inspect the given 'readcharfun' source once, before using it, instead of
for each character read.  This moves a bunch of branches away from the
critical path, with separate functions for different source types.
Replace some preprocessor macros with functions.

* src/lread.c (READCHAR, UNREAD, READCHAR_REPORT_MULTIBYTE)
(FROM_FILE_P): Remove; use corresponding functions instead.
All callers adapted.
(source_t): New struct that takes the place of the `readcharfun` and
`readbyte` arguments in many places.
(init_source)
(source_buffer_get, source_buffer_unget)
(source_marker_get, source_marker_unget)
(source_string_get, source_string_unget)
(source_file_get, source_file_unget)
(source_function_get, source_function_unget)
(from_file_p, unreadbyte_from_file):
New.
(readbyte_from_stdio): Replace `readbyte_from_file`.
(readchar, unreadchar): Rewrite.
(lisp_file_lexical_cookie, readevalloop, read_internal_start):
Create a source_t for use during reading.  All signatures and functions
called adapted.
(read_char_escape): Remove check for an error that can no longer occur.

(cherry picked from commit cd3727f7e0607a152a97b534ee09a2cb8ac6cb84)
src/lread.c