Browse Source

- Replace QMap by QHash for faster lookups

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
b54c4ae028
  1. 4
      src/GUI.cpp
  2. 8
      src/GUI.h

4
src/GUI.cpp

@ -1093,7 +1093,7 @@ void GUI::deletePermanently(){
// Delete item from download list // Delete item from download list
DLListModel->removeRow(sortedIndex.first); DLListModel->removeRow(sortedIndex.first);
// Get handle and remove the torrent // Get handle and remove the torrent
QMap<QString, torrent_handle>::iterator it = handles.find(fileName); QHash<QString, torrent_handle>::iterator it = handles.find(fileName);
if(it != handles.end() && it.key() == fileName) { if(it != handles.end() && it.key() == fileName) {
torrent_handle h = it.value(); torrent_handle h = it.value();
savePath = QString::fromUtf8(h.save_path().string().c_str()); savePath = QString::fromUtf8(h.save_path().string().c_str());
@ -1164,7 +1164,7 @@ void GUI::deleteSelection(){
// Delete item from download list // Delete item from download list
DLListModel->removeRow(sortedIndex.first); DLListModel->removeRow(sortedIndex.first);
// Get handle and remove the torrent // Get handle and remove the torrent
QMap<QString, torrent_handle>::iterator it = handles.find(fileName); QHash<QString, torrent_handle>::iterator it = handles.find(fileName);
if(it != handles.end() && it.key() == fileName) { if(it != handles.end() && it.key() == fileName) {
torrent_handle h = it.value(); torrent_handle h = it.value();
s->remove_torrent(h); s->remove_torrent(h);

8
src/GUI.h

@ -23,7 +23,7 @@
#define GUI_H #define GUI_H
#include <QMainWindow> #include <QMainWindow>
#include <QMap> #include <QHash>
#include <QProcess> #include <QProcess>
#include <QTcpServer> #include <QTcpServer>
#include <QTcpSocket> #include <QTcpSocket>
@ -63,10 +63,10 @@ class GUI : public QMainWindow, private Ui::MainWindow{
// Bittorrent // Bittorrent
session *s; session *s;
std::pair<unsigned short, unsigned short> listenPorts; std::pair<unsigned short, unsigned short> listenPorts;
QMap<QString, torrent_handle> handles; QHash<QString, torrent_handle> handles;
QTimer *checkConnect; QTimer *checkConnect;
QTimer *timerScan; QTimer *timerScan;
QMap<QString, QStringList> trackerErrors; QHash<QString, QStringList> trackerErrors;
trackerLogin *tracker_login; trackerLogin *tracker_login;
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers; QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
downloadThread *downloader; downloadThread *downloader;
@ -90,7 +90,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
previewSelect *previewSelection; previewSelect *previewSelection;
QProcess *previewProcess; QProcess *previewProcess;
// Search related // Search related
QMap<QString, QString> searchResultsUrls; QHash<QString, QString> searchResultsUrls;
QProcess *searchProcess; QProcess *searchProcess;
bool search_stopped; bool search_stopped;
bool no_search_results; bool no_search_results;

Loading…
Cancel
Save