[Pkg-owncloud-commits] [owncloud-client] 256/333: Use sane datastructure in Utility::StopWatch
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit e0b6395d1881263ecc456482a4684ea085b96c38
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Fri Mar 28 09:50:13 2014 +0100
Use sane datastructure in Utility::StopWatch
We don't want to logging to be O(N^2)
Also avoid usage of macro when possible
---
src/mirall/utility.cpp | 14 +++-----------
src/mirall/utility.h | 3 +--
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index 1a37939..d00392b 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -490,7 +490,7 @@ bool Utility::isLinux()
#endif
}
-# define STOPWATCH_END_TAG QLatin1String("_STOPWATCH_END")
+static const char STOPWATCH_END_TAG[] = "_STOPWATCH_END";
void Utility::StopWatch::start()
{
@@ -510,8 +510,7 @@ quint64 Utility::StopWatch::addLapTime( const QString& lapName )
start();
}
quint64 re = _timer.elapsed();
- QPair<QString, quint64> p(lapName, re);
- _lapTimes.append(p);
+ _lapTimes[lapName] = re;
return re;
}
@@ -533,14 +532,7 @@ QDateTime Utility::StopWatch::timeOfLap( const QString& lapName ) const
quint64 Utility::StopWatch::durationOfLap( const QString& lapName ) const
{
- QPair<QString, quint64> lapPair;
-
- foreach( lapPair, _lapTimes ) {
- if( lapPair.first == lapName ) {
- return lapPair.second;
- }
- }
- return 0;
+ return _lapTimes.value(lapName, 0);
}
diff --git a/src/mirall/utility.h b/src/mirall/utility.h
index 90aca54..60db688 100644
--- a/src/mirall/utility.h
+++ b/src/mirall/utility.h
@@ -18,7 +18,6 @@
#include <QString>
#include <QByteArray>
#include <QDateTime>
-#include <QPair>
#include <QElapsedTimer>
class QWidget;
@@ -70,7 +69,7 @@ namespace Utility
class StopWatch {
private:
- QList<QPair<QString, quint64> > _lapTimes;
+ QHash<QString, quint64> _lapTimes;
QDateTime _startTime;
QElapsedTimer _timer;
public:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list