Skip to content

Commit 9da9112

Browse files
committed
Don't count lines in iostreams counter filter
1 parent d1c2cf7 commit 9da9112

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

core/src/counter64.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// See http://www.boost.org/libs/iostreams for documentation.
77

8-
// Same as counter.hpp, but 64-bit
8+
// Same as counter.hpp, but 64-bit and no line counter
99

1010
#ifndef BOOST_IOSTREAMS_COUNTER64_HPP_INCLUDED
1111
#define BOOST_IOSTREAMS_COUNTER64_HPP_INCLUDED
@@ -14,9 +14,7 @@
1414
# pragma once
1515
#endif
1616

17-
#include <algorithm> // count.
1817
#include <boost/iostreams/categories.hpp>
19-
#include <boost/iostreams/char_traits.hpp>
2018
#include <boost/iostreams/operations.hpp>
2119
#include <boost/iostreams/pipeline.hpp>
2220

@@ -29,7 +27,7 @@ namespace boost { namespace iostreams {
2927
// Template name: basic_counter.
3028
// Template parameters:
3129
// Ch - The character type.
32-
// Description: Filter which counts lines and characters.
30+
// Description: Filter which counts characters.
3331
//
3432
template<typename Ch>
3533
class basic_counter64 {
@@ -41,10 +39,9 @@ class basic_counter64 {
4139
multichar_tag,
4240
optimally_buffered_tag
4341
{ };
44-
explicit basic_counter64(int64_t first_line = 0, int64_t first_char = 0)
45-
: lines_(first_line), chars_(first_char)
42+
explicit basic_counter64(int64_t first_char = 0)
43+
: chars_(first_char)
4644
{ }
47-
int64_t lines() const { return lines_; }
4845
int64_t characters() const { return chars_; }
4946
std::streamsize optimal_buffer_size() const { return 0; }
5047

@@ -54,7 +51,6 @@ class basic_counter64 {
5451
std::streamsize result = iostreams::read(src, s, n);
5552
if (result == -1)
5653
return -1;
57-
lines_ += std::count(s, s + result, char_traits<Ch>::newline());
5854
chars_ += result;
5955
return result;
6056
}
@@ -63,12 +59,10 @@ class basic_counter64 {
6359
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
6460
{
6561
std::streamsize result = iostreams::write(snk, s, n);
66-
lines_ += std::count(s, s + result, char_traits<Ch>::newline());
6762
chars_ += result;
6863
return result;
6964
}
7065
private:
71-
int64_t lines_;
7266
int64_t chars_;
7367
};
7468
BOOST_IOSTREAMS_PIPABLE(basic_counter64, 1)

0 commit comments

Comments
 (0)