From 284f122433ce77839ec2ac92b7861c422d76c860 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 28 Jun 2019 14:58:47 +0900 Subject: [PATCH] refactor: replace for-loop by comment output --- toml/serializer.hpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index 4711236..01b894f 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -633,11 +633,8 @@ format(const basic_value& v, std::size_t w = 80u, std::ostringstream oss; if(!v.comments().empty()) { - for(const auto& c : v.comments()) - { - oss << '#' << c << '\n'; - } - oss << '\n'; + oss << v.comments(); + oss << '\n'; // to split the file comment from the first element } oss << visit(serializer(w, fprec, false), v); return oss.str(); @@ -657,11 +654,8 @@ operator<<(std::basic_ostream& os, const basic_value& v) if(!v.comments().empty()) { - for(const auto& c : v.comments()) - { - os << '#' << c << '\n'; - } - os << '\n'; + os << v.comments(); + os << '\n'; // to split the file comment from the first element } // the root object can't be an inline table. so pass `false`. os << visit(serializer(w, fprec, false), v);