Commit 35acd6f1 authored by Scott Wheeler's avatar Scott Wheeler

Very significant startup time optimization for large collections -- hey, I

knew there was a reason I wrote that StringHash class.  I think I was just
too lazy to write a remove() method for it so I used my SortedStringList
instead.  Anyway, switching over to the StringHash makes startup time for
a collection of 12,500 items about 8x faster.

svn path=/trunk/kdemultimedia/juk/; revision=242601
parent 344c07b7
......@@ -25,7 +25,7 @@
#include <qvaluevector.h>
#include <qptrstack.h>
#include "sortedstringlist.h"
#include "stringhash.h"
#include "playlistsearch.h"
#include "tagguesser.h"
......@@ -429,7 +429,7 @@ private slots:
void slotCreateGroup() { emit signalCreatePlaylist(selectedItems()); }
SortedStringList m_members;
StringHash m_members;
int m_currentColumn;
int m_processed;
bool m_allowDuplicates;
......@@ -74,6 +74,26 @@ bool StringHash::contains(const QString &value) const
return bool(i);
bool StringHash::remove(const QString &value)
int h = hash(value);
Node *previous = 0;
Node *i = m_table[h];
while(i && i->key != value) {
previous = i;
i = i->next;
return false;
previous->next = i->next;
delete i;
return true;
QStringList StringHash::values() const
......@@ -30,6 +30,7 @@ public:
bool insert(const QString &value);
bool contains(const QString &value) const;
bool remove(const QString &value);
* Returns a sorted list of the values.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment