Skip to content

Commit c1a299a

Browse files
committed
Remove unnecessary stream classes
1 parent 2aaaf4a commit c1a299a

File tree

3 files changed

+15
-80
lines changed

3 files changed

+15
-80
lines changed

include/boost/json/detail/stream.hpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace detail {
1515

1616
class const_stream
1717
{
18-
friend class local_const_stream;
19-
2018
char const* p_;
2119
char const* end_;
2220

@@ -89,36 +87,6 @@ class const_stream
8987
}
9088
};
9189

92-
class local_const_stream
93-
: public const_stream
94-
{
95-
const_stream& src_;
96-
97-
public:
98-
explicit
99-
local_const_stream(
100-
const_stream& src) noexcept
101-
: const_stream(src)
102-
, src_(src)
103-
{
104-
}
105-
106-
~local_const_stream()
107-
{
108-
src_.p_ = p_;
109-
}
110-
111-
void
112-
clip(std::size_t n) noexcept
113-
{
114-
if(static_cast<std::size_t>(
115-
src_.end_ - p_) > n)
116-
end_ = p_ + n;
117-
else
118-
end_ = src_.end_;
119-
}
120-
};
121-
12290
class const_stream_wrapper
12391
{
12492
const char*& p_;
@@ -239,8 +207,6 @@ class clipped_const_stream
239207

240208
class stream
241209
{
242-
friend class local_stream;
243-
244210
char* p_;
245211
char* end_;
246212

@@ -324,26 +290,6 @@ class stream
324290
}
325291
};
326292

327-
class local_stream
328-
: public stream
329-
{
330-
stream& src_;
331-
332-
public:
333-
explicit
334-
local_stream(
335-
stream& src)
336-
: stream(src)
337-
, src_(src)
338-
{
339-
}
340-
341-
~local_stream()
342-
{
343-
src_.p_ = p_;
344-
}
345-
};
346-
347293
} // detail
348294
BOOST_JSON_NS_END
349295

include/boost/json/impl/serializer.ipp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ suspend(
7676
template<bool StackEmpty>
7777
bool
7878
serializer::
79-
write_null(stream& ss0)
79+
write_null(stream& ss)
8080
{
81-
local_stream ss(ss0);
8281
if(! StackEmpty && ! st_.empty())
8382
{
8483
state st;
@@ -118,9 +117,8 @@ do_nul4:
118117
template<bool StackEmpty>
119118
bool
120119
serializer::
121-
write_true(stream& ss0)
120+
write_true(stream& ss)
122121
{
123-
local_stream ss(ss0);
124122
if(! StackEmpty && ! st_.empty())
125123
{
126124
state st;
@@ -160,9 +158,8 @@ do_tru4:
160158
template<bool StackEmpty>
161159
bool
162160
serializer::
163-
write_false(stream& ss0)
161+
write_false(stream& ss)
164162
{
165-
local_stream ss(ss0);
166163
if(! StackEmpty && ! st_.empty())
167164
{
168165
state st;
@@ -208,10 +205,8 @@ do_fal5:
208205
template<bool StackEmpty>
209206
bool
210207
serializer::
211-
write_string(stream& ss0)
208+
write_string(stream& ss)
212209
{
213-
local_stream ss(ss0);
214-
local_const_stream cs(cs0_);
215210
if(! StackEmpty && ! st_.empty())
216211
{
217212
state st;
@@ -254,19 +249,19 @@ do_str1:
254249
do_str2:
255250
if(BOOST_JSON_LIKELY(ss))
256251
{
257-
std::size_t n = cs.remain();
252+
std::size_t n = cs0_.remain();
258253
if(BOOST_JSON_LIKELY(n > 0))
259254
{
260255
if(ss.remain() > n)
261256
n = detail::count_unescaped(
262-
cs.data(), n);
257+
cs0_.data(), n);
263258
else
264259
n = detail::count_unescaped(
265-
cs.data(), ss.remain());
260+
cs0_.data(), ss.remain());
266261
if(n > 0)
267262
{
268-
ss.append(cs.data(), n);
269-
cs.skip(n);
263+
ss.append(cs0_.data(), n);
264+
cs0_.skip(n);
270265
if(! ss)
271266
return suspend(state::str2);
272267
}
@@ -287,12 +282,12 @@ do_str2:
287282
do_str3:
288283
while(BOOST_JSON_LIKELY(ss))
289284
{
290-
if(BOOST_JSON_LIKELY(cs))
285+
if(BOOST_JSON_LIKELY(cs0_))
291286
{
292-
auto const ch = *cs;
287+
auto const ch = *cs0_;
293288
auto const c = esc[static_cast<
294289
unsigned char>(ch)];
295-
++cs;
290+
++cs0_;
296291
if(! c)
297292
{
298293
ss.append(ch);
@@ -385,9 +380,8 @@ do_utf5:
385380
template<bool StackEmpty>
386381
bool
387382
serializer::
388-
write_number(stream& ss0)
383+
write_number(stream& ss)
389384
{
390-
local_stream ss(ss0);
391385
if(StackEmpty || st_.empty())
392386
{
393387
switch(jv_->kind())
@@ -455,10 +449,9 @@ write_number(stream& ss0)
455449
template<bool StackEmpty>
456450
bool
457451
serializer::
458-
write_array(stream& ss0)
452+
write_array(stream& ss)
459453
{
460454
array const* pa;
461-
local_stream ss(ss0);
462455
array::const_iterator it;
463456
array::const_iterator end;
464457
if(StackEmpty || st_.empty())
@@ -521,10 +514,9 @@ do_arr4:
521514
template<bool StackEmpty>
522515
bool
523516
serializer::
524-
write_object(stream& ss0)
517+
write_object(stream& ss)
525518
{
526519
object const* po;
527-
local_stream ss(ss0);
528520
object::const_iterator it;
529521
object::const_iterator end;
530522
if(StackEmpty || st_.empty())

include/boost/json/serializer.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ class serializer
5959
// VFALCO Too many streams
6060
using stream = detail::stream;
6161
using const_stream = detail::const_stream;
62-
using local_stream = detail::local_stream;
63-
using local_const_stream =
64-
detail::local_const_stream;
6562

6663
using fn_t = bool (serializer::*)(stream&);
6764

0 commit comments

Comments
 (0)