changeset 790:9f68155c75b0

speeding up LinearAlgebra::ParseVector()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 May 2019 08:29:01 +0200
parents 5aa728500586
children 907189734acd
files Framework/Toolbox/DicomStructureSet.cpp Framework/Toolbox/LinearAlgebra.cpp
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Toolbox/DicomStructureSet.cpp	Tue May 28 07:48:57 2019 +0200
+++ b/Framework/Toolbox/DicomStructureSet.cpp	Tue May 28 08:29:01 2019 +0200
@@ -31,7 +31,6 @@
 
 #include <limits>
 #include <stdio.h>
-#include <boost/lexical_cast.hpp>
 #include <boost/geometry.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
@@ -422,7 +421,6 @@
                    << static_cast<int>(structures_[i].green_) << ","
                    << static_cast<int>(structures_[i].blue_) << ")";
 
-
       // These temporary variables avoid allocating many vectors in the loop below
       OrthancPlugins::DicomPath countPointsPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
                                                 DICOM_TAG_CONTOUR_SEQUENCE, 0,
--- a/Framework/Toolbox/LinearAlgebra.cpp	Tue May 28 07:48:57 2019 +0200
+++ b/Framework/Toolbox/LinearAlgebra.cpp	Tue May 28 08:29:01 2019 +0200
@@ -26,7 +26,6 @@
 #include <Core/Toolbox.h>
 
 #include <stdio.h>
-#include <boost/lexical_cast.hpp>
 #include <boost/numeric/ublas/lu.hpp>
 
 namespace OrthancStone
@@ -71,9 +70,16 @@
       {
         try
         {
-          target[i] = boost::lexical_cast<double>(items[i]);
+          /**
+           * We don't use "boost::lexical_cast<>" here, as it is very
+           * slow. As we are parsing many doubles, we prefer to use
+           * the standard "std::stod" function:
+           * http://www.cplusplus.com/reference/string/stod/
+           **/
+          
+          target[i] = std::stod(items[i]);
         }
-        catch (boost::bad_lexical_cast&)
+        catch (std::exception&)
         {
           target.clear();
           return false;