2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 14:25:52 +00:00

Rework tests against Epsnodes to compare to the singleton

Dynamic casts are slower than plain comparisons so rework epsnode comparison
to use comparisons to the singleton epsnode instead of dynamic_casts.
This commit is contained in:
John Johansen
2010-11-09 11:47:37 -08:00
parent 6801346b81
commit ac9553de19

View File

@@ -568,11 +568,10 @@ void normalize_tree(Node *t, int dir)
return;
for (;;) {
if (!dynamic_cast<EpsNode *>(t->child[!dir]) &&
((dynamic_cast<AltNode *>(t) &&
dynamic_cast<EpsNode *>(t->child[dir])) ||
(dynamic_cast<CatNode *>(t) &&
dynamic_cast<EpsNode *>(t->child[dir])))) {
if ((&epsnode == t->child[dir]) &&
(&epsnode != t->child[!dir]) &&
(dynamic_cast<AltNode *>(t) ||
dynamic_cast<CatNode *>(t))) {
// (E | a) -> (a | E)
// Ea -> aE
Node *c = t->child[dir];
@@ -740,7 +739,7 @@ static Node *basic_alt_factor(Node *t, int dir)
static Node *basic_simplify(Node *t, int dir)
{
if (dynamic_cast<CatNode *>(t) &&
dynamic_cast<EpsNode *>(t->child[!dir])) {
&epsnode == t->child[!dir]) {
// aE -> a
Node *tmp = t->child[dir];
t->child[dir] = NULL;