mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-13 17:44:54 +00:00
Revert "libsepol: cache ebitmap cardinality value"
This reverts commit542e878690
. After6968ea9775
("libsepol: make ebitmap_cardinality() of linear complexity"), the caching only saves ~0.06 % of total semodule -BN running time (on x86_64 without using the POPCNT instruction), so it's no longer worth the added complexity. Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
parent
fc093ad757
commit
9fe58752e8
@ -37,7 +37,6 @@ typedef struct ebitmap_node {
|
||||
typedef struct ebitmap {
|
||||
ebitmap_node_t *node; /* first node in the bitmap */
|
||||
uint32_t highbit; /* highest position in the total bitmap */
|
||||
unsigned int cardinality; /* cached value of cardinality */
|
||||
} ebitmap_t;
|
||||
|
||||
#define ebitmap_is_empty(e) (((e)->highbit) == 0)
|
||||
|
@ -67,7 +67,6 @@ int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1)
|
||||
ebitmap_destroy(dst);
|
||||
dst->node = tmp.node;
|
||||
dst->highbit = tmp.highbit;
|
||||
dst->cardinality = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -131,13 +130,9 @@ unsigned int ebitmap_cardinality(ebitmap_t *e1)
|
||||
unsigned int count = 0;
|
||||
ebitmap_node_t *n;
|
||||
|
||||
if (e1->cardinality || e1->highbit == 0)
|
||||
return e1->cardinality;
|
||||
|
||||
for (n = e1->node; n; n = n->next) {
|
||||
count += __builtin_popcountll(n->map);
|
||||
}
|
||||
e1->cardinality = count;
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -201,7 +196,6 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
|
||||
}
|
||||
|
||||
dst->highbit = src->highbit;
|
||||
dst->cardinality = src->cardinality;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -317,7 +311,6 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value)
|
||||
free(n);
|
||||
}
|
||||
}
|
||||
e->cardinality = 0; /* invalidate cached cardinality */
|
||||
return 0;
|
||||
}
|
||||
prev = n;
|
||||
@ -348,7 +341,6 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value)
|
||||
e->node = new;
|
||||
}
|
||||
|
||||
e->cardinality = 0; /* invalidate cached cardinality */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -368,7 +360,6 @@ void ebitmap_destroy(ebitmap_t * e)
|
||||
|
||||
e->highbit = 0;
|
||||
e->node = 0;
|
||||
e->cardinality = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user