Skip to content

Commit 192fc78

Browse files
committed
remove the stringstream from unique_stream_writer
1 parent fe56a8d commit 192fc78

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

src/stan/callbacks/unique_stream_writer.hpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ class unique_stream_writer final : public writer {
7575
*/
7676
void operator()() {
7777
if (!empty_) {
78-
std::stringstream streamer;
79-
streamer.precision(output_.get()->precision());
80-
streamer << comment_prefix_ << std::endl;
81-
*output_ << streamer.str();
78+
*output_ << comment_prefix_ << std::endl;
8279
}
8380
}
8481

@@ -89,10 +86,7 @@ class unique_stream_writer final : public writer {
8986
*/
9087
void operator()(const std::string& message) {
9188
if (!empty_) {
92-
std::stringstream streamer;
93-
streamer.precision(output_.get()->precision());
94-
streamer << comment_prefix_ << message << std::endl;
95-
*output_ << streamer.str();
89+
*output_ << comment_prefix_ << message << std::endl;
9690
}
9791
}
9892

@@ -127,18 +121,15 @@ class unique_stream_writer final : public writer {
127121
template <class T>
128122
void write_vector(const std::vector<T>& v) {
129123
if (!empty_) {
130-
if (v.empty())
124+
if (v.empty()) {
131125
return;
132-
using const_iter = typename std::vector<T>::const_iterator;
133-
const_iter last = v.end();
126+
}
127+
auto last = v.end();
134128
--last;
135-
std::stringstream streamer;
136-
streamer.precision(output_.get()->precision());
137-
for (const_iter it = v.begin(); it != last; ++it) {
138-
streamer << *it << ",";
129+
for (auto it = v.begin(); it != last; ++it) {
130+
*output_ << *it << ",";
139131
}
140-
streamer << v.back() << std::endl;
141-
*output_ << streamer.str();
132+
*output_ << v.back() << std::endl;
142133
}
143134
}
144135
};

0 commit comments

Comments
 (0)