From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Cc: "Christian Göttsche" <cgzones@googlemail.com>
Subject: [PATCH v2 7/7] libsepol: skip superfluous memset calls in ebitmap operations
Date: Tue, 19 Jul 2022 17:30:44 +0200 [thread overview]
Message-ID: <20220719153045.70041-7-cgzones@googlemail.com> (raw)
In-Reply-To: <20220719153045.70041-1-cgzones@googlemail.com>
The three members of struct ebitmap_node are all unconditionally
initialized. Hinder compilers to optimize malloc() and memset() into
calloc(), which might be slightly slower. Especially affects
ebitmap_or().
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
libsepol/src/ebitmap.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c
index 7d26f949..3ec1042f 100644
--- a/libsepol/src/ebitmap.c
+++ b/libsepol/src/ebitmap.c
@@ -31,7 +31,6 @@ int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2)
ebitmap_destroy(dst);
return -ENOMEM;
}
- memset(new, 0, sizeof(ebitmap_node_t));
if (n1 && n2 && n1->startbit == n2->startbit) {
new->startbit = n1->startbit;
new->map = n1->map | n2->map;
@@ -290,7 +289,6 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
ebitmap_destroy(dst);
return -ENOMEM;
}
- memset(new, 0, sizeof(ebitmap_node_t));
new->startbit = n->startbit;
new->map = n->map;
new->next = 0;
@@ -430,7 +428,6 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value)
new = (ebitmap_node_t *) malloc(sizeof(ebitmap_node_t));
if (!new)
return -ENOMEM;
- memset(new, 0, sizeof(ebitmap_node_t));
new->startbit = startbit;
new->map = (MAPBIT << (bit - new->startbit));
--
2.36.1
next prev parent reply other threads:[~2022-07-19 15:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 15:30 [PATCH v2 1/7] libsepol/tests: add ebitmap tests Christian Göttsche
2022-07-19 15:30 ` [PATCH v2 2/7] libsepol: add ebitmap_init_range Christian Göttsche
2022-07-19 15:30 ` [PATCH v2 3/7] libsepol/cil: use ebitmap_init_range Christian Göttsche
2022-07-19 15:30 ` [PATCH v2 4/7] libsepol: optimize ebitmap_not Christian Göttsche
2022-07-19 15:30 ` [PATCH v2 5/7] libsepol: optimize ebitmap_and Christian Göttsche
2022-07-19 15:30 ` [PATCH v2 6/7] libsepol: optimize ebitmap_xor Christian Göttsche
2022-07-19 15:30 ` Christian Göttsche [this message]
2022-07-20 19:51 ` [PATCH v2 1/7] libsepol/tests: add ebitmap tests James Carter
2022-08-09 15:19 ` James Carter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220719153045.70041-7-cgzones@googlemail.com \
--to=cgzones@googlemail.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).