From 0d8de448ef746aea7215f6f654660500dc9601d2 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 31 Dec 2015 18:36:02 +0100 Subject: qsgbatchrenderer: memset nodes instead of using a constructor. Since all fields are now POD, and we want them all zero'd anyway. Increases delegates_rect benchmark by maybe 40 or so instances per frame. Change-Id: I1ca2da1e82edb70485b584cb52f4be2f5ffbcf08 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 27 +++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index afc564710e..5dbbc22870 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -101,7 +101,11 @@ public: : available(PageSize) , allocated(PageSize) { - for (int i=0; iat(pos); p->available--; p->allocated.setBit(pos); - Type *t = new (mem) Type(); + Type *t = (Type*)mem; return t; } @@ -163,8 +167,9 @@ public: if (!page->allocated.testBit(index)) qFatal("Double delete in allocator: page=%d, index=%d", pageIndex , index); - // Call the destructor - page->at(index)->~Type(); + // Zero this instance as we're done with it. + void *mem = page->at(index); + memset(mem, 0, sizeof(Type)); page->allocated[index] = false; page->available++; @@ -440,21 +445,9 @@ struct Batch QDataBuffer drawSets; }; +// NOTE: Node is zero-allocated by the Allocator. struct Node { - Node() - : sgNode(0) - , parent(0) - , data(0) - , firstChild(0) - , nextSibling(0) - , lastChild(0) - , dirtyState(0) - , isOpaque(false) - , isBatchRoot(false) - { - } - QSGNode *sgNode; Node *parent; void *data; -- cgit v1.2.3