Another try to speed up rates.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@8890 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2014-07-29 22:07:19 +00:00
parent 98741bbe32
commit e168691097
3 changed files with 9 additions and 7 deletions

View File

@ -1913,7 +1913,7 @@ protected:
/* utilities.cpp ------------------------------- */
int spinner;
std::map<std::string, double> gfw_map;
std::map<std::string, int> rates_map;
std::map<const char *, int> rates_map;
/* new after release of Version 3 */
std::map<std::string, std::vector < std::string> > sum_species_map;

View File

@ -9135,7 +9135,10 @@ read_rates(void)
case OPTION_DEFAULT: /* read rate name */
ptr = line;
copy_token(token, &ptr, &l);
rate_ptr = rate_search(token, &n);
{
const char *name = string_hsave(token);
rate_ptr = rate_search(name, &n);
}
if (rate_ptr == NULL)
{
rates =

View File

@ -1649,9 +1649,8 @@ rate_search(const char *name, int *n)
* if found, the address of the pp_assemblage element
* if not found, NULL
*/
std::string str(name);
std::map<std::string, int>::iterator it;
it = rates_map.find(str);
std::map<const char *, int>::iterator it;
it = rates_map.find(name);
if (it != rates_map.end())
{
*n = it->second;
@ -1669,14 +1668,14 @@ rate_search(const char *name, int *n)
if (strcmp_nocase(rates[i].name, name) == 0)
{
*n = i;
rates_map[str] = i;
rates_map[name] = i;
return (&(rates[i]));
}
}
/*
* rate name not found
*/
rates_map[str] = *n;
rates_map[name] = *n;
return (NULL);
}