aboutsummaryrefslogtreecommitdiff
path: root/libbutl/char-scanner.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-05-26 17:20:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-05-26 17:20:30 +0200
commit1b57e247b8d1a7a41a8ee45d6d524c71edd63a81 (patch)
treeb226e55b4ea9c2c4ecba286ac9e3dccf9d09292d /libbutl/char-scanner.cxx
parent4c4f3160258e799c65dccc80c00bb7ef16daac01 (diff)
Optimize char_scanner if used with ifdstream
Diffstat (limited to 'libbutl/char-scanner.cxx')
-rw-r--r--libbutl/char-scanner.cxx20
1 files changed, 14 insertions, 6 deletions
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 <libbutl/char-scanner.hxx>
-#include <istream>
-
using namespace std;
namespace butl
{
+ char_scanner::
+ char_scanner (istream& is, bool crlf)
+ : is_ (is),
+ buf_ (dynamic_cast<fdbuf*> (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')
{