diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-30 15:43:52 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-31 14:11:35 +0000 |
commit | 29c482280901cfcd526e93b2b0f34f43973def72 (patch) | |
tree | e2263563689a709c1fd6e10ba627fbfd2d87d229 /sources/shiboken2/libshiboken/basewrapper_p.h | |
parent | 056e58b48b3b8858c4d4ac0d1c593b5f7fb46d0c (diff) |
libshiboken: Fix container types
Change the ref count map to a unordered_multimap and the remaining
lists to vectors.
A linked std::list is not suitable for the lists
used in libshiboken.
Task-number: PYSIDE-727
Change-Id: Ibd65486a58cf43ac66b981bea65597df5a732b63
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper_p.h')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper_p.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper_p.h b/sources/shiboken2/libshiboken/basewrapper_p.h index ebd2648e7..a61d5c947 100644 --- a/sources/shiboken2/libshiboken/basewrapper_p.h +++ b/sources/shiboken2/libshiboken/basewrapper_p.h @@ -43,10 +43,10 @@ #include "sbkpython.h" #include "basewrapper.h" -#include <list> -#include <map> +#include <unordered_map> #include <set> #include <string> +#include <vector> struct SbkObject; struct SbkObjectType; @@ -58,7 +58,7 @@ namespace Shiboken * This mapping associates a method and argument of an wrapper object with the wrapper of * said argument when it needs the binding to help manage its reference count. */ -typedef std::map<std::string, std::list<PyObject*> > RefCountMap; +typedef std::unordered_multimap<std::string, PyObject *> RefCountMap; /// Linked list of SbkBaseWrapper pointers typedef std::set<SbkObject*> ChildrenList; @@ -153,7 +153,7 @@ namespace Shiboken /** * Utility function used to transform a PyObject that implements sequence protocol into a std::list. **/ -std::list<SbkObject*> splitPyObject(PyObject* pyObj); +std::vector<SbkObject *> splitPyObject(PyObject* pyObj); /** * Visitor class used by walkOnClassHierarchy function. @@ -189,6 +189,8 @@ private: class BaseAccumulatorVisitor : public HierarchyVisitor { public: + typedef std::vector<SbkObjectType *> Result; + BaseAccumulatorVisitor() {} void visit(SbkObjectType* node) @@ -196,9 +198,9 @@ public: m_bases.push_back(node); } - std::list<SbkObjectType*> bases() const { return m_bases; } + Result bases() const { return m_bases; } private: - std::list<SbkObjectType*> m_bases; + Result m_bases; }; class GetIndexVisitor : public HierarchyVisitor @@ -226,7 +228,7 @@ public: void visit(SbkObjectType* node); void done(); protected: - std::list<std::pair<void*, SbkObjectType*> > m_ptrs; + std::vector<std::pair<void *, SbkObjectType *> > m_ptrs; SbkObject* m_pyObj; }; @@ -260,7 +262,7 @@ inline int getNumberOfCppBaseClasses(PyTypeObject* baseType) return visitor.count(); } -inline std::list<SbkObjectType*> getCppBaseClasses(PyTypeObject* baseType) +inline std::vector<SbkObjectType *> getCppBaseClasses(PyTypeObject* baseType) { BaseAccumulatorVisitor visitor; walkThroughClassHierarchy(baseType, &visitor); |