From 1b57e247b8d1a7a41a8ee45d6d524c71edd63a81 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 May 2017 17:20:30 +0200 Subject: Optimize char_scanner if used with ifdstream --- libbutl/char-scanner.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libbutl/char-scanner.cxx') diff --git a/libbutl/char-scanner.cxx b/libbutl/char-scanner.cxx index 42a72cc..a2baaf3 100644 --- a/libbutl/char-scanner.cxx +++ b/libbutl/char-scanner.cxx @@ -4,12 +4,20 @@ #include -#include - using namespace std; namespace butl { + char_scanner:: + char_scanner (istream& is, bool crlf) + : is_ (is), + buf_ (dynamic_cast (is.rdbuf ())), + gptr_ (nullptr), + egptr_ (nullptr), + crlf_ (crlf) + { + } + auto char_scanner:: peek () -> xchar { @@ -22,14 +30,14 @@ namespace butl if (eos_) return xchar (xchar::traits_type::eof (), line, column); - xchar::int_type v (is_.peek ()); + int_type v (peek_ ()); if (v == xchar::traits_type::eof ()) eos_ = true; else if (crlf_ && v == 0x0D) { - is_.get (); - xchar::int_type v1 (is_.peek ()); + get_ (); + int_type v1 (peek_ ()); if (v1 != '\n') { @@ -62,7 +70,7 @@ namespace butl // if (!eos (c)) { - is_.get (); + get_ (); if (c == '\n') { -- cgit v1.1