From da88eaf7034e9f5f8d87b1d9ee864588ed52f69e Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 23 Sep 2019 21:52:10 +0200 Subject: [PATCH] Moved tagpair-lambda up for better readability. --- src/lib/export/adoc.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/lib/export/adoc.cpp b/src/lib/export/adoc.cpp index 43f7178..51abfff 100644 --- a/src/lib/export/adoc.cpp +++ b/src/lib/export/adoc.cpp @@ -183,25 +183,27 @@ namespace remwharead _out << "== Tags\n\n"; vector sortedtags(tags.size()); std::move(tags.begin(), tags.end(), sortedtags.begin()); - std::sort(sortedtags.begin(), sortedtags.end(), - [](const tagpair &a, tagpair &b) - { - if (a.second.size() != b.second.size()) - { // Sort by number of occurrences if they are different. - return a.second.size() > b.second.size(); - } - else - { // Sort by tag names otherwise. - std::locale loc; - const std::collate &coll = - std::use_facet>(loc); - return (coll.compare( - a.first.data(), a.first.data() - + a.first.length(), - b.first.data(), b.first.data() - + b.first.length()) == -1); - } - }); + + const auto compare_tags = + [](const tagpair &a, tagpair &b) + { + if (a.second.size() != b.second.size()) + { // Sort by number of occurrences if they are different. + return a.second.size() > b.second.size(); + } + else + { // Sort by tag names otherwise. + const std::locale loc; + const std::collate &coll = + std::use_facet>(loc); + return ( + coll.compare( + a.first.data(), a.first.data() + a.first.length(), + b.first.data(), b.first.data() + b.first.length()) + == -1); + } + }; + std::sort(sortedtags.begin(), sortedtags.end(), compare_tags); bool othertags = false; // Have we printed “Less used tags” already? for (const auto &tag : sortedtags)