Eliminated unnecessary string copying in Reactor / ReactorNet

This commit is contained in:
Ray Speth 2012-10-12 20:34:41 +00:00
parent 11a11bea79
commit c404c31879
10 changed files with 14 additions and 15 deletions

View file

@ -55,7 +55,7 @@ public:
virtual void updateState(doublereal* y);
virtual size_t componentIndex(std::string nm) const;
virtual size_t componentIndex(const std::string& nm) const;
protected:

View file

@ -69,7 +69,7 @@ public:
double distance() const {
return m_dist;
}
virtual size_t componentIndex(std::string nm) const;
virtual size_t componentIndex(const std::string& nm) const;
protected:

View file

@ -127,8 +127,7 @@ public:
return m_pname[p];
}
// virtual std::string component(int k) const;
virtual size_t componentIndex(std::string nm) const;
virtual size_t componentIndex(const std::string& nm) const;
protected:
//! Pointer to the homogeneous Kinetics object that handles the reactions

View file

@ -30,7 +30,7 @@ class ReactorBase
public:
ReactorBase(std::string name = "(none)");
explicit ReactorBase(const std::string& name = "(none)");
virtual ~ReactorBase() {}
//-----------------------------------------------------
@ -41,7 +41,7 @@ public:
std::string name() const {
return m_name;
}
void setName(std::string name) {
void setName(const std::string& name) {
m_name = name;
}
@ -157,7 +157,7 @@ public:
//@}
int error(std::string msg) const {
int error(const std::string& msg) const {
writelog("Error: "+msg);
return 1;
}
@ -185,7 +185,7 @@ protected:
private:
void tilt(std::string method="") const {
void tilt(const std::string& method="") const {
throw CanteraError("ReactorBase::"+method,
"ReactorBase method called!");
}

View file

@ -113,7 +113,7 @@ public:
return m_integ->sensitivity(k, p)/m_integ->solution(k);
}
double sensitivity(std::string species, size_t p, int reactor=0) {
double sensitivity(const std::string& species, size_t p, int reactor=0) {
size_t k = globalComponentIndex(species, reactor);
return sensitivity(k, p);
}
@ -135,7 +135,7 @@ public:
return m_ntotpar;
}
size_t globalComponentIndex(std::string species, size_t reactor=0);
size_t globalComponentIndex(const std::string& species, size_t reactor=0);
void connect(size_t i, size_t j) {
m_connect[j*m_nr + i] = 1;

View file

@ -276,7 +276,7 @@ void ConstPressureReactor::evalEqs(doublereal time, doublereal* y,
}
}
size_t ConstPressureReactor::componentIndex(string nm) const
size_t ConstPressureReactor::componentIndex(const string& nm) const
{
if (nm == "H") {
return 0;

View file

@ -125,7 +125,7 @@ void FlowReactor::evalEqs(doublereal time, doublereal* y,
}
size_t FlowReactor::componentIndex(string nm) const
size_t FlowReactor::componentIndex(const string& nm) const
{
if (nm == "X") {
return 0;

View file

@ -318,7 +318,7 @@ void Reactor::addSensitivityReaction(size_t rxn)
}
size_t Reactor::componentIndex(string nm) const
size_t Reactor::componentIndex(const string& nm) const
{
if (nm == "U") {
return 0;

View file

@ -12,7 +12,7 @@ using namespace std;
namespace Cantera
{
ReactorBase::ReactorBase(string name) : m_nsp(0),
ReactorBase::ReactorBase(const string& name) : m_nsp(0),
m_thermo(0),
m_vol(1.0),
m_vol0(1.0),

View file

@ -268,7 +268,7 @@ void ReactorNet::getInitialConditions(doublereal t0,
}
}
size_t ReactorNet::globalComponentIndex(string species, size_t reactor)
size_t ReactorNet::globalComponentIndex(const string& species, size_t reactor)
{
size_t start = 0;
size_t n;