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>
This commit is contained in:
Tomaz Canabrava 2015-01-14 22:18:20 -02:00 committed by Dirk Hohndel
parent dc7397b06e
commit 54898b15ff

View file

@ -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())) {