From d33b074c30b23896da1b46bbeaae51ab2120c7c3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 14 Oct 2014 22:56:42 -0700 Subject: [PATCH] Don't call input::seek_fn unnecessarily --- spec/runtime/helpers/spy_reader.cc | 3 +-- src/runtime/lexer.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/runtime/helpers/spy_reader.cc b/spec/runtime/helpers/spy_reader.cc index bc71df74..8af2cfd6 100644 --- a/spec/runtime/helpers/spy_reader.cc +++ b/spec/runtime/helpers/spy_reader.cc @@ -64,8 +64,7 @@ const char * SpyReader::read(size_t *bytes_read) { } int SpyReader::seek(size_t pos) { - if (position != pos) - strings_read.push_back(""); + strings_read.push_back(""); position = pos; return 0; } diff --git a/src/runtime/lexer.c b/src/runtime/lexer.c index ff6277ef..3d3cbb26 100644 --- a/src/runtime/lexer.c +++ b/src/runtime/lexer.c @@ -9,7 +9,8 @@ static const char *empty_chunk = ""; static void ts_lexer_read_next_chunk(TSLexer *lexer) { TSInput input = lexer->input; - input.seek_fn(input.data, lexer->current_position); + if (lexer->current_position.bytes != lexer->chunk_start + lexer->chunk_size) + input.seek_fn(input.data, lexer->current_position); lexer->chunk_start = lexer->current_position.bytes; lexer->chunk = input.read_fn(input.data, &lexer->chunk_size); if (!lexer->chunk_size)