changeset 3382:a2862d4484f5

optimization of Toolbox::TokenizeString()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 May 2019 07:47:18 +0200
parents a6c590cb8181
children 367d0b618d70
files Core/Toolbox.cpp
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Tue May 28 07:33:10 2019 +0200
+++ b/Core/Toolbox.cpp	Tue May 28 07:47:18 2019 +0200
@@ -956,7 +956,18 @@
                                const std::string& value,
                                char separator)
   {
+    size_t countSeparators = 0;
+    
+    for (size_t i = 0; i < value.size(); i++)
+    {
+      if (value[i] == separator)
+      {
+        countSeparators++;
+      }
+    }
+    
     result.clear();
+    result.reserve(countSeparators + 1);
 
     std::string currentItem;