diff --git a/include/asm/lexer.hpp b/include/asm/lexer.hpp index 2dbc6e38b..7500d11c7 100644 --- a/include/asm/lexer.hpp +++ b/include/asm/lexer.hpp @@ -7,14 +7,15 @@ #include #include #include -#include // BUFSIZ #include #include #include #include "platform.hpp" // SSIZE_MAX -#define LEXER_BUF_SIZE BUFSIZ +// This value is a compromise between `LexerState` allocation performance when `mmap` works, and +// buffering performance when it doesn't/can't (e.g. when piping a file into RGBASM). +#define LEXER_BUF_SIZE 64 // The buffer needs to be large enough for the maximum `lexerState->peek()` lookahead distance static_assert(LEXER_BUF_SIZE > 1, "Lexer buffer size is too small"); // This caps the size of buffer reads, and according to POSIX, passing more than SSIZE_MAX is UB diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 947e76e0b..3ca0728c1 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include