From bb9d71b4fee2cc4abf55e0dcbadf85c6cbe0d07d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 2 Feb 2015 02:13:54 +0100 Subject: [PATCH] Replace loops with algorithms. --- Source/cmRST.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index c261d5796..cb61ed995 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -484,19 +484,12 @@ void cmRST::UnindentLines(std::vector& lines) } } - // Drop leading blank lines. - size_t leadingEmpty = 0; - for(size_t i = 0; i < lines.size() && lines[i].empty(); ++i) - { - ++leadingEmpty; - } + std::vector::const_iterator it = lines.begin(); + size_t leadingEmpty = std::distance(it, cmFindNot(lines, std::string())); - // Drop trailing blank lines. - size_t trailingEmpty = 0; - for(size_t i = lines.size(); i > 0 && lines[i-1].empty(); --i) - { - ++trailingEmpty; - } + std::vector::const_reverse_iterator rit = lines.rbegin(); + size_t trailingEmpty = std::distance(rit, + cmFindNot(cmReverseRange(lines), std::string())); std::vector::iterator contentEnd = cmRotate(lines.begin(),