From d4d3ec4988749ee8350f400ec1ae25665f442685 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 20 Dec 2015 16:39:49 -0500 Subject: [PATCH] Common: Eliminated side-effect version of split --- src/common/Color.cpp | 3 +-- src/common/text.cpp | 19 ------------------- src/common/text.h | 1 - 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/common/Color.cpp b/src/common/Color.cpp index ea70b580..fc6859c6 100644 --- a/src/common/Color.cpp +++ b/src/common/Color.cpp @@ -127,8 +127,7 @@ Color::Color (const std::string& spec) : _value (0) { // Split spec into words. - std::vector words; - split (words, spec, ' '); + std::vector words = split (spec, ' '); // Construct the color as two separate colors, then blend them later. This // make it possible to declare a color such as "color1 on black", and have diff --git a/src/common/text.cpp b/src/common/text.cpp index e6ca20f1..ae60be04 100644 --- a/src/common/text.cpp +++ b/src/common/text.cpp @@ -47,25 +47,6 @@ std::vector split (const std::string& input, const char delimiter) return results; } -//////////////////////////////////////////////////////////////////////////////// -void split ( - std::vector& results, - const std::string& input, - const char delimiter) -{ - results.clear (); - std::string::size_type start = 0; - std::string::size_type i; - while ((i = input.find (delimiter, start)) != std::string::npos) - { - results.push_back (input.substr (start, i - start)); - start = i + 1; - } - - if (input.length ()) - results.push_back (input.substr (start)); -} - //////////////////////////////////////////////////////////////////////////////// const std::string format (std::string& value) { diff --git a/src/common/text.h b/src/common/text.h index f1224f9e..505ce84a 100644 --- a/src/common/text.h +++ b/src/common/text.h @@ -33,7 +33,6 @@ // text.cpp, Non-UTF-8 aware. std::vector split (const std::string&, const char); -void split (std::vector&, const std::string&, const char); const std::string format (std::string&); const std::string format (const char*); const std::string formatHex (int);