[Kst] extragear/graphics/kst/src/libkst
Eli Fidler
eli at staikos.net
Tue Jan 30 19:14:54 CET 2007
SVN commit 628626 by fidler:
speed up object insertion about 3 times -- this is very important with lots of objects
M +5 -1 kstobject.h
M +14 -7 kstobjectcollection.h
--- trunk/extragear/graphics/kst/src/libkst/kstobject.h #628625:628626
@@ -88,7 +88,11 @@
}
QString tag() const { return _tag; }
- QStringList fullTag() const { return _context + QStringList(_tag); }
+ QStringList fullTag() const {
+ QStringList ft(_context);
+ ft << _tag;
+ return ft;
+ }
QStringList context() const { return _context; }
unsigned int components() const {
--- trunk/extragear/graphics/kst/src/libkst/kstobjectcollection.h #628625:628626
@@ -21,6 +21,8 @@
// NAMEDEBUG: 0 for no debug, 1 for some debug, 2 for more debug, 3 for all debug
#define NAMEDEBUG 0
+#include <qintdict.h>
+
#include "ksdebug.h"
#include "kstobject.h"
@@ -114,7 +116,7 @@
private:
QValueList<KstObjectTreeNode<T> *> relatedNodes(T *obj);
- void relatedNodesHelper(T *o, KstObjectTreeNode<T> *n, QValueList<KstObjectTreeNode<T> *>& nodes);
+ void relatedNodesHelper(T *o, KstObjectTreeNode<T> *n, QIntDict<KstObjectTreeNode<T> >& nodes);
// must be called AFTER the object is added to the index, while holding a write lock
void updateDisplayComponents(T *obj);
@@ -672,13 +674,13 @@
// recursion helper
template <class T>
-void KstObjectCollection<T>::relatedNodesHelper(T *o, KstObjectTreeNode<T> *n, QValueList<KstObjectTreeNode<T> *>& nodes) {
+void KstObjectCollection<T>::relatedNodesHelper(T *o, KstObjectTreeNode<T> *n, QIntDict<KstObjectTreeNode<T> >& nodes) {
- if (n->object() && n->object() != o && !nodes.contains(n)) {
+ if (n->object() && n->object() != o && !nodes[(long)n]) {
#if NAMEDEBUG > 2
kstdDebug() << "Found related node to \"" << o->tag().tagString() << "\": \"" << n->object()->tag().tagString() << "\"" << endl;
#endif
- nodes << n;
+ nodes.insert((long)n, n);
}
if (!n->children().isEmpty()) {
@@ -696,10 +698,11 @@
// There should not be any duplicates in the returned list.
template <class T>
QValueList<KstObjectTreeNode<T> *> KstObjectCollection<T>::relatedNodes(T *o) {
- QValueList<KstObjectTreeNode<T> *> nodes;
+ QIntDict<KstObjectTreeNode<T> > nodes;
+ QValueList<KstObjectTreeNode<T> *> outNodes;
if (!o) {
- return nodes;
+ return outNodes;
}
#if NAMEDEBUG > 2
@@ -717,7 +720,11 @@
}
}
- return nodes;
+ QIntDictIterator<KstObjectTreeNode<T> > i(nodes);
+ for (; i.current(); ++i) {
+ outNodes << i.current();
+ }
+ return outNodes;
}
More information about the Kst
mailing list