mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-04 00:05:14 +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:
@@ -568,11 +568,10 @@ void normalize_tree(Node *t, int dir)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!dynamic_cast<EpsNode *>(t->child[!dir]) &&
|
if ((&epsnode == t->child[dir]) &&
|
||||||
((dynamic_cast<AltNode *>(t) &&
|
(&epsnode != t->child[!dir]) &&
|
||||||
dynamic_cast<EpsNode *>(t->child[dir])) ||
|
(dynamic_cast<AltNode *>(t) ||
|
||||||
(dynamic_cast<CatNode *>(t) &&
|
dynamic_cast<CatNode *>(t))) {
|
||||||
dynamic_cast<EpsNode *>(t->child[dir])))) {
|
|
||||||
// (E | a) -> (a | E)
|
// (E | a) -> (a | E)
|
||||||
// Ea -> aE
|
// Ea -> aE
|
||||||
Node *c = t->child[dir];
|
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)
|
static Node *basic_simplify(Node *t, int dir)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<CatNode *>(t) &&
|
if (dynamic_cast<CatNode *>(t) &&
|
||||||
dynamic_cast<EpsNode *>(t->child[!dir])) {
|
&epsnode == t->child[!dir]) {
|
||||||
// aE -> a
|
// aE -> a
|
||||||
Node *tmp = t->child[dir];
|
Node *tmp = t->child[dir];
|
||||||
t->child[dir] = NULL;
|
t->child[dir] = NULL;
|
||||||
|
Reference in New Issue
Block a user