From ec3bf59e1ea5262d5ed722bba6c188728d76b2f3 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Tue, 7 Mar 2017 18:07:09 +0000 Subject: [PATCH] Now that we never re-parse anything we can always dicard old data. --- re2c/src/ast/scanner.cc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/re2c/src/ast/scanner.cc b/re2c/src/ast/scanner.cc index 0c5a75ae..3651096d 100644 --- a/re2c/src/ast/scanner.cc +++ b/re2c/src/ast/scanner.cc @@ -47,25 +47,21 @@ void Scanner::fill (uint32_t need) { if(!eof) { - /* Do not get rid of anything when rFlag is active. Otherwise - * get rid of everything that was already handedout. */ - if (!opts->rFlag) + /* Get rid of everything that was already parsed. */ + const ptrdiff_t diff = tok - bot; + if (diff > 0) { - const ptrdiff_t diff = tok - bot; - if (diff > 0) - { - const size_t move = static_cast (top - tok); - memmove (bot, tok, move); - tok -= diff; - mar -= diff; - ptr -= diff; - cur -= diff; - pos -= diff; - lim -= diff; - ctx -= diff; - } + const size_t move = static_cast (top - tok); + memmove (bot, tok, move); + tok -= diff; + mar -= diff; + ptr -= diff; + cur -= diff; + pos -= diff; + lim -= diff; + ctx -= diff; } - /* In crease buffer size. */ + /* Increase buffer size. */ if (BSIZE > need) { need = BSIZE; -- 2.40.0