Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

std-- #11

Closed
wants to merge 2 commits into from

2 participants

@luisgabriel

No description provided.

luisgabriel added some commits
@luisgabriel luisgabriel Monitor: Removing unnecessary use of std classes
Signed-off-by: Luis Gabriel Lima <lampih@gmail.com>
f89f18d
@luisgabriel luisgabriel Monitor: Avoiding unnecessary QMap lookups
Each indexing in a QMap has O(log n) time complexity.

This commit removes some unnecessary lookups to m_rememberedJobs
in order to does not compromise the performance of Iceberg.

Signed-off-by: Luis Gabriel Lima <lampih@gmail.com>
d3b2dd8
@hugopl
Owner

The netname will never have unicode characters, libicecc doesn't support unicode characters, so we don't need the QString overhead, better to stay with the QByteArray

@hugopl

Maybe would be better to use a QList instead of a StringList

@hugopl
Owner

shit, github ate my characters, I said QList[QByteArray], not just QList.

@luisgabriel

Fair enough. I'll update the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 22, 2012
  1. @luisgabriel

    Monitor: Removing unnecessary use of std classes

    luisgabriel authored
    Signed-off-by: Luis Gabriel Lima <lampih@gmail.com>
  2. @luisgabriel

    Monitor: Avoiding unnecessary QMap lookups

    luisgabriel authored
    Each indexing in a QMap has O(log n) time complexity.
    
    This commit removes some unnecessary lookups to m_rememberedJobs
    in order to does not compromise the performance of Iceberg.
    
    Signed-off-by: Luis Gabriel Lima <lampih@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 26 deletions.
  1. +22 −23 src/monitor.cpp
  2. +3 −3 src/monitor.h
View
45 src/monitor.cpp
@@ -28,16 +28,12 @@
#include "hostinfo.h"
#include "statusview.h"
-#include <icecc/comm.h>
#include <QSocketNotifier>
#include <QTimer>
-#include <list>
-#include <iostream>
+#include <icecc/comm.h>
#include <ctime>
-using namespace std;
-
Monitor::Monitor(HostInfoManager* m, QObject *parent)
: QObject(parent),
m_hostInfoManager(m),
@@ -96,28 +92,29 @@ void Monitor::slotCheckScheduler()
if (m_scheduler)
return;
- list<string> names;
+ QStringList names;
if (!m_currentNetName.isEmpty())
- names.push_front(m_currentNetName.data());
+ names.push_front(m_currentNetName);
else
names.push_front("ICECREAM");
if (!qgetenv("USE_SCHEDULER").isEmpty())
names.push_front(""); // try $USE_SCHEDULER
- for (list<string>::const_iterator it = names.begin(); it != names.end(); ++it) {
- m_currentNetName = it->c_str();
+ QStringList::const_iterator it = names.constBegin();
+ for (; it != names.constEnd(); ++it) {
+ m_currentNetName = *it;
+
if (!m_discover || m_discover->timed_out()) {
delete m_discover;
- m_discover = new DiscoverSched (m_currentNetName.data());
+ m_discover = new DiscoverSched(m_currentNetName.toStdString());
}
m_scheduler = m_discover->try_get_scheduler();
-
if (m_scheduler) {
- m_hostInfoManager->setSchedulerName(QString::fromLatin1(m_discover->schedulerName().data()));
- m_hostInfoManager->setNetworkName(QString::fromLatin1(m_discover->networkName().data()));
+ m_hostInfoManager->setSchedulerName(QString::fromStdString(m_discover->schedulerName()));
+ m_hostInfoManager->setNetworkName(QString::fromStdString(m_discover->networkName()));
m_scheduler->setBulkTransfer();
delete m_discover;
@@ -203,10 +200,11 @@ void Monitor::handleGetcs(Msg* _m)
if (!m)
return;
- m_rememberedJobs[m->job_id] = Job(m->job_id, m->clientid,
- m->filename.c_str(),
- m->lang == CompileJob::Lang_C ? "C" : "C++");
- m_view->update(m_rememberedJobs[m->job_id]);
+ Job job(m->job_id, m->clientid, QString::fromStdString(m->filename),
+ m->lang == CompileJob::Lang_C ? "C" : "C++");
+
+ m_rememberedJobs[m->job_id] = job;
+ m_view->update(job);
}
void Monitor::handleLocalBegin(Msg* _m)
@@ -215,10 +213,11 @@ void Monitor::handleLocalBegin(Msg* _m)
if (!m)
return;
- m_rememberedJobs[m->job_id] = Job(m->job_id, m->hostid,
- m->file.c_str(), "C++");
- m_rememberedJobs[m->job_id].setState(Job::LocalOnly);
- m_view->update(m_rememberedJobs[m->job_id]);
+ Job job(m->job_id, m->hostid, QString::fromStdString(m->file), "C++");
+ job.setState(Job::LocalOnly);
+
+ m_rememberedJobs[m->job_id] = job;
+ m_view->update(job);
}
void Monitor::handleLocalDone(Msg* _m)
@@ -250,10 +249,10 @@ void Monitor::handleStats(Msg* _m)
if (!m)
return;
- QStringList statmsg = QString(m->statmsg.c_str()).split('\n');
+ QStringList message = QString::fromStdString(m->statmsg).split('\n');
HostInfo::StatsMap stats;
QStringList::ConstIterator it;
- for (it = statmsg.constBegin(); it != statmsg.constEnd(); ++it) {
+ for (it = message.constBegin(); it != message.constEnd(); ++it) {
QString key = *it;
key = key.left(key.indexOf(':'));
QString value = *it;
View
6 src/monitor.h
@@ -42,8 +42,8 @@ class Monitor : public QObject
Monitor(HostInfoManager*, QObject* parent);
~Monitor();
- void setCurrentNet(const QByteArray& name) { m_currentNetName = name; }
- QByteArray currentNet() const { return m_currentNetName; }
+ void setCurrentNet(const QString& name) { m_currentNetName = name; }
+ QString currentNet() const { return m_currentNetName; }
void setCurrentView(StatusView*, bool rememberJobs);
void checkScheduler(bool deleteit = false);
@@ -69,7 +69,7 @@ private slots:
StatusView* m_view;
JobList m_rememberedJobs;
MsgChannel* m_scheduler;
- QByteArray m_currentNetName;
+ QString m_currentNetName;
bool m_schedulerOnline;
DiscoverSched* m_discover;
Something went wrong with that request. Please try again.