diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-14 22:18:20 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-15 14:23:46 +1300 |
commit | 54898b15ffbcd92b839a450a943cfe0ffd8b6799 (patch) | |
tree | ab9a8283ad2de5d20150f3ec017a97f842ec6353 /qt-ui/profile | |
parent | dc7397b06e9a555aac707ede1aea699ca3dad230 (diff) | |
download | subsurface-54898b15ffbcd92b839a450a943cfe0ffd8b6799.tar.gz |
Do not free the membuffer, reuse it
This is an attempt to make fewer calls to alloc functions when the mouse
is moving.
We were creating a membuffer, filling it (malloc / realloc), then freeing
it just after use. but we could simply hold that allocated area and reuse
it again.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index dbef866c5..ea3a74901 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -234,14 +234,16 @@ void ToolTipItem::refresh(const QPointF &pos) struct plot_data *entry; static QPixmap tissues(16,60); static QPainter painter(&tissues); + static struct membuffer mb = { 0 }; + int time = timeAxis->valueAt(pos); if (time == lastTime) return; lastTime = time; clear(); - struct membuffer mb = { 0 }; + mb.len = 0; entry = get_plot_details_new(&pInfo, time, &mb); if (entry) { tissues.fill(); @@ -262,7 +264,6 @@ void ToolTipItem::refresh(const QPointF &pos) } addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); } - free_buffer(&mb); Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemBoundingRect ,Qt::DescendingOrder, scene()->views().first()->transform())) { |