libsepol: prepend instead of append to filename_trans list
Currently expand_filename_trans() function use much CPU time to find end of the state->out->filename_trans list. This is not needed because data can be prepended instead of appended to the list. This ends with 10% speed-up of various se* commands (semodule, setsebool). Signed-off-by: Adam Tkac <atkac@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
c43f5b1d34
commit
d21ec5a560
|
@ -1352,16 +1352,11 @@ static int copy_role_trans(expand_state_t * state, role_trans_rule_t * rules)
|
|||
static int expand_filename_trans(expand_state_t *state, filename_trans_rule_t *rules)
|
||||
{
|
||||
unsigned int i, j;
|
||||
filename_trans_t *new_trans, *tail, *cur_trans;
|
||||
filename_trans_t *new_trans, *cur_trans;
|
||||
filename_trans_rule_t *cur_rule;
|
||||
ebitmap_t stypes, ttypes;
|
||||
ebitmap_node_t *snode, *tnode;
|
||||
|
||||
/* start at the end of the list */
|
||||
tail = state->out->filename_trans;
|
||||
while (tail && tail->next)
|
||||
tail = tail->next;
|
||||
|
||||
cur_rule = rules;
|
||||
while (cur_rule) {
|
||||
uint32_t mapped_otype;
|
||||
|
@ -1422,11 +1417,8 @@ static int expand_filename_trans(expand_state_t *state, filename_trans_rule_t *r
|
|||
return -1;
|
||||
}
|
||||
memset(new_trans, 0, sizeof(*new_trans));
|
||||
if (tail)
|
||||
tail->next = new_trans;
|
||||
else
|
||||
state->out->filename_trans = new_trans;
|
||||
tail = new_trans;
|
||||
new_trans->next = state->out->filename_trans;
|
||||
state->out->filename_trans = new_trans;
|
||||
|
||||
new_trans->name = strdup(cur_rule->name);
|
||||
if (!new_trans->name) {
|
||||
|
|
Loading…
Reference in New Issue