summaryrefslogtreecommitdiff
path: root/py_eval.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-20 02:14:53 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commitb84f676946941df6f7e8476d77d1db0cbe7736c5 (patch)
tree9ee7c7a2d3b7496b38ad127519210adfeced2241 /py_eval.cc
parent539370ff1b37772e9f11439f652ffd3583beeedb (diff)
downloadfork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.gz
fork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.bz2
fork-ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.zip
Did some optimization and memory cleanup
Diffstat (limited to 'py_eval.cc')
-rw-r--r--py_eval.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/py_eval.cc b/py_eval.cc
index 95b104d5..c38542c7 100644
--- a/py_eval.cc
+++ b/py_eval.cc
@@ -50,7 +50,7 @@ struct python_run
{
object result;
python_run(python_interpreter_t * intepreter,
- const std::string& str, int input_mode)
+ const string& str, int input_mode)
: result(handle<>(borrowed(PyRun_String(str.c_str(), input_mode,
intepreter->nspace.ptr(),
intepreter->nspace.ptr())))) {}
@@ -68,14 +68,14 @@ python_interpreter_t::python_interpreter_t(xml::xpath_t::scope_t * parent)
detail::init_module("ledger", &initialize_ledger_for_python);
}
-object python_interpreter_t::import(const std::string& str)
+object python_interpreter_t::import(const string& str)
{
assert(Py_IsInitialized());
try {
PyObject * mod = PyImport_Import(PyString_FromString(str.c_str()));
if (! mod)
- throw error(std::string("Failed to import Python module ") + str);
+ throw error(string("Failed to import Python module ") + str);
object newmod(handle<>(borrowed(mod)));
@@ -84,20 +84,20 @@ object python_interpreter_t::import(const std::string& str)
dict m_nspace(handle<>(borrowed(PyModule_GetDict(mod))));
nspace.update(m_nspace);
#else
- nspace[std::string(PyModule_GetName(mod))] = newmod;
+ nspace[string(PyModule_GetName(mod))] = newmod;
#endif
return newmod;
}
catch (const error_already_set&) {
PyErr_Print();
- throw error(std::string("Importing Python module ") + str);
+ throw error(string("Importing Python module ") + str);
}
}
object python_interpreter_t::eval(std::istream& in, py_eval_mode_t mode)
{
bool first = true;
- std::string buffer;
+ string buffer;
buffer.reserve(4096);
while (! in.eof()) {
@@ -128,7 +128,7 @@ object python_interpreter_t::eval(std::istream& in, py_eval_mode_t mode)
}
}
-object python_interpreter_t::eval(const std::string& str, py_eval_mode_t mode)
+object python_interpreter_t::eval(const string& str, py_eval_mode_t mode)
{
try {
int input_mode;
@@ -170,7 +170,7 @@ void python_interpreter_t::functor_t::operator()(value_t& result,
else if (PyObject * err = PyErr_Occurred()) {
PyErr_Print();
throw new xml::xpath_t::calc_error
- (std::string("While calling Python function '") + name() + "'");
+ (string("While calling Python function '") + name() + "'");
} else {
assert(0);
}
@@ -182,7 +182,7 @@ void python_interpreter_t::functor_t::operator()(value_t& result,
catch (const error_already_set&) {
PyErr_Print();
throw new xml::xpath_t::calc_error
- (std::string("While calling Python function '") + name() + "'");
+ (string("While calling Python function '") + name() + "'");
}
}