aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2015-12-31 18:36:02 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2016-04-06 09:05:51 +0000
commit0d8de448ef746aea7215f6f654660500dc9601d2 (patch)
tree1d66a1b063e3fd72a6dea5a63ec99777bc4d515c
parent8f7fb1fb4db2ade390521ac5485dc17006823b57 (diff)
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 <gunnar@sletta.org>
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h27
1 files 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; i<PageSize; ++i) blocks[i] = i;
+ for (int i=0; i<PageSize; ++i)
+ blocks[i] = i;
+
+ // Zero out all new pages.
+ memset(data, 0, sizeof(data));
}
const Type *at(uint index) const
@@ -153,7 +157,7 @@ public:
void *mem = p->at(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<DrawSet> 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;