aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/bindingmanager.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-18 12:39:27 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-30 13:46:50 +0000
commit8c3b9c0d847656f7a254490047d40cf54e2847a1 (patch)
tree20eeb21c47ab95a97cdd7161d748b3df7fab0be6 /sources/shiboken2/libshiboken/bindingmanager.cpp
parentfee4a7f9fa7177e94ab4853b049fca093e2849fc (diff)
libshiboken: Refactor loops
Avoid repeated invocation of container.end() in the loop condition by either assigning to a variable or use range-based-for where possible. Use auto for iterators to allow for changing the container type. Task-number: PYSIDE-727 Change-Id: I5217207a3a7fb60823ccbcbf0915bf6cf21a3e4d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/bindingmanager.cpp')
-rw-r--r--sources/shiboken2/libshiboken/bindingmanager.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp
index 2cc7847a8..9d0e3d62e 100644
--- a/sources/shiboken2/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken2/libshiboken/bindingmanager.cpp
@@ -78,14 +78,13 @@ public:
file << "digraph D {\n";
- Edges::const_iterator i = m_edges.begin();
- for (; i != m_edges.end(); ++i) {
- SbkObjectType* node1 = i->first;
+ for (auto i = m_edges.begin(), end = m_edges.end(); i != end; ++i) {
+ auto node1 = reinterpret_cast<const PyTypeObject *>(i->first);
const NodeList& nodeList = i->second;
- NodeList::const_iterator j = nodeList.begin();
- for (; j != nodeList.end(); ++j) {
- file << '"' << reinterpret_cast<PyTypeObject *>(*j)->tp_name << "\" -> \""
- << reinterpret_cast<PyTypeObject *>(node1)->tp_name << "\"\n";
+ for (const SbkObjectType *o : nodeList) {
+ auto node2 = reinterpret_cast<const PyTypeObject *>(o);
+ file << '"' << node2->tp_name << "\" -> \""
+ << node1->tp_name << "\"\n";
}
}
file << "}\n";
@@ -97,9 +96,8 @@ public:
Edges::const_iterator edgesIt = m_edges.find(type);
if (edgesIt != m_edges.end()) {
const NodeList& adjNodes = m_edges.find(type)->second;
- NodeList::const_iterator i = adjNodes.begin();
- for (; i != adjNodes.end(); ++i) {
- SbkObjectType* newType = identifyType(cptr, *i, baseType);
+ for (SbkObjectType *node : adjNodes) {
+ SbkObjectType* newType = identifyType(cptr, node, baseType);
if (newType)
return newType;
}
@@ -128,10 +126,9 @@ static void showWrapperMap(const WrapperMap& wrapperMap)
if (Py_VerboseFlag > 0) {
fprintf(stderr, "-------------------------------\n");
fprintf(stderr, "WrapperMap: %p (size: %d)\n", &wrapperMap, (int) wrapperMap.size());
- WrapperMap::const_iterator iter;
- for (iter = wrapperMap.begin(); iter != wrapperMap.end(); ++iter) {
- const SbkObject *sbkObj = iter->second;
- fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", iter->first,
+ for (auto it = wrapperMap.begin(), end = wrapperMap.end(); it != end; ++it) {
+ const SbkObject *sbkObj = it->second;
+ fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", it->first,
static_cast<const void *>(sbkObj),
(Py_TYPE(sbkObj))->tp_name,
int(reinterpret_cast<const PyObject *>(sbkObj)->ob_refcnt));