aboutsummaryrefslogtreecommitdiff
path: root/async.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-12-17 16:10:00 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2015-01-13 11:47:56 +0000
commitee82310f8a6cc9ba9e8d1ac892f1a3cfc0debd8c (patch)
tree2e70198af3d637f0f9b99ecb0a99bff4867c5d42 /async.c
parente012b78cf5bc42f20ef1a1f78383035f2293ceea (diff)
block: replace g_new0 with g_new for bottom half allocation.
This saves about 15% of the clock cycles spent on allocation. Using the slice allocator does not add a visible improvement; allocation is faster than malloc, while freeing seems to be slower. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'async.c')
-rw-r--r--async.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/async.c b/async.c
index 572f239e2c..2be88cc9e9 100644
--- a/async.c
+++ b/async.c
@@ -44,10 +44,12 @@ struct QEMUBH {
QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque)
{
QEMUBH *bh;
- bh = g_new0(QEMUBH, 1);
- bh->ctx = ctx;
- bh->cb = cb;
- bh->opaque = opaque;
+ bh = g_new(QEMUBH, 1);
+ *bh = (QEMUBH){
+ .ctx = ctx,
+ .cb = cb,
+ .opaque = opaque,
+ };
qemu_mutex_lock(&ctx->bh_lock);
bh->next = ctx->first_bh;
/* Make sure that the members are ready before putting bh into list */