mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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:
parent
dc7397b06e
commit
54898b15ff
1 changed files with 3 additions and 2 deletions
|
@ -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())) {
|
||||
|
|
Loading…
Reference in a new issue