From 1af807e588067db5b20430027afce5eb3c1a7869 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 7 Jul 2020 06:27:13 +0200 Subject: [PATCH] RSS generator: write_line(): Move endtag detection into lambda. --- src/generators/rss.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/generators/rss.cpp b/src/generators/rss.cpp index 5c4eac9..0fb4254 100644 --- a/src/generators/rss.cpp +++ b/src/generators/rss.cpp @@ -45,18 +45,19 @@ using std::chrono::system_clock; void write_line(ostream &out, const uint8_t spaces, const string_view rsstag, const string_view value) { - string endtag; - // If there is a space in the rsstag, use only the part up until the space - // for the ending rsstag. - const size_t pos = rsstag.find(' '); - if (pos == string_view::npos) + // clang-format off + const string endtag{[&rsstag] { - endtag = rsstag; - } - else - { - endtag = rsstag.substr(0, pos); - } + // If there is a space in the rsstag, use only the part up until the + // space for the ending RSS tag. + const size_t pos = rsstag.find(' '); + if (pos == string_view::npos) + { + return rsstag; + } + return rsstag.substr(0, pos); + }()}; + // clang-format off out << string(spaces, ' '); out << '<' << rsstag << '>' << value << "\n";