aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-02-18 17:28:45 -0200
committerHugo Lima <hugo.lima@openbossa.org>2010-02-18 18:01:47 -0200
commitf425ded9520c965202b62b1c2d172608f803497b (patch)
tree10552e182698730d9b539e34a78ddd98c8c557b9 /libshiboken
parentd0442ea7fdd623238674334889b6b096fa07b9d0 (diff)
Some optimizations and code cleanup on conversion code for std containers.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/conversions.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index be27fd1d9..47d7ef6a8 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -418,16 +418,13 @@ struct Converter_std_list
{
return PySequence_Check(const_cast<PyObject*>(pyObj));
}
- static PyObject* toPython(StdList cppobj)
+ static PyObject* toPython(const StdList& cppobj)
{
PyObject* result = PyList_New((int) cppobj.size());
- typedef typename StdList::iterator IT;
- IT it;
- int idx = 0;
- for (it = cppobj.begin(); it != cppobj.end(); it++) {
+ typename StdList::const_iterator it = cppobj.begin();
+ for (int idx = 0; it != cppobj.end(); ++it, ++idx) {
typename StdList::value_type vh(*it);
PyList_SET_ITEM(result, idx, Converter<typename StdList::value_type>::toPython(vh));
- idx++;
}
return result;
}
@@ -449,7 +446,7 @@ struct Converter_std_pair
{
return PySequence_Check(const_cast<PyObject*>(pyObj));
}
- static PyObject* toPython(StdPair cppobj)
+ static PyObject* toPython(const StdPair& cppobj)
{
typename StdPair::first_type first(cppobj.first);
typename StdPair::second_type second(cppobj.second);
@@ -477,13 +474,12 @@ struct Converter_std_map
return PyDict_Check(const_cast<PyObject*>(pyObj));
}
- static PyObject* toPython(StdMap cppobj)
+ static PyObject* toPython(const StdMap& cppobj)
{
PyObject* result = PyDict_New();
- typedef typename StdMap::iterator IT;
- IT it;
+ typename StdMap::const_iterator it = cppobj.begin();
- for (it = cppobj.begin(); it != cppobj.end(); it++) {
+ for (; it != cppobj.end(); ++it) {
typename StdMap::key_type h_key((*it).first);
typename StdMap::mapped_type h_val((*it).second);
PyDict_SetItem(result,