Tried optimizing get_total_element using std::strings

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@2374 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2007-11-07 18:28:25 +00:00
parent e7ec5c7691
commit 3f93ab5a1c

View File

@ -853,6 +853,7 @@ double cxxSolution::get_total_element(char *string)const
double d = 0.0;
for (it = this->totals.begin(); it != this->totals.end(); ++it)
{
#ifdef SKIP
char token[MAX_LENGTH], token1[MAX_LENGTH];
int n;
char *ptr;
@ -863,6 +864,19 @@ double cxxSolution::get_total_element(char *string)const
if (strcmp(token1, string) == 0) {
d += it->second;
}
#endif
std::string ename(string);
std::string current_ename(string);
std::basic_string <char>::size_type indexCh;
indexCh = current_ename.find("(");
if (indexCh != std::string::npos)
{
current_ename = current_ename.substr(0, indexCh);
}
if (current_ename == ename)
{
d += it->second;
}
}
return(d);
}