From 54898b15ffbcd92b839a450a943cfe0ffd8b6799 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 14 Jan 2015 22:18:20 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/divetooltipitem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'qt-ui/profile/divetooltipitem.cpp') 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())) { -- cgit v1.2.3-70-g09d2