mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Now that we have a proper class we don't need a functor to do comparisons,
we can fold it into the classes operator<. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Kees Cook <kees@ubuntu.com>
This commit is contained in:
parent
d452f53576
commit
35b7ee91eb
2 changed files with 8 additions and 16 deletions
|
@ -63,7 +63,7 @@ State *DFA::find_target_state(NodeMap &nodemap, list<State *> &work_queue,
|
|||
|
||||
ProtoState index(nodes);
|
||||
|
||||
map<ProtoState, State *, deref_less_than>::iterator x = nodemap.find(index);
|
||||
map<ProtoState, State *>::iterator x = nodemap.find(index);
|
||||
|
||||
if (x == nodemap.end()) {
|
||||
/* set of nodes isn't known so create new state, and nodes to
|
||||
|
|
|
@ -51,24 +51,16 @@ public:
|
|||
{
|
||||
hash = hash_NodeSet(n);
|
||||
}
|
||||
};
|
||||
|
||||
/* Comparison operator for a ProtoState
|
||||
* Compare set hashes, and if the sets have the same hash
|
||||
* do compare pointer comparison on set of <Node *>, the pointer comparison
|
||||
* allows us to determine which Sets of <Node *> we have seen already from
|
||||
* new ones when constructing the DFA.
|
||||
*/
|
||||
struct deref_less_than {
|
||||
bool operator()(ProtoState const &lhs, ProtoState const &rhs)const
|
||||
bool operator<(ProtoState const &rhs)const
|
||||
{
|
||||
if (lhs.hash == rhs.hash) {
|
||||
if (lhs.nodes->size() == rhs.nodes->size())
|
||||
return *(lhs.nodes) < *(rhs.nodes);
|
||||
if (hash == rhs.hash) {
|
||||
if (nodes->size() == rhs.nodes->size())
|
||||
return *nodes < *(rhs.nodes);
|
||||
else
|
||||
return lhs.nodes->size() < rhs.nodes->size();
|
||||
return nodes->size() < rhs.nodes->size();
|
||||
} else {
|
||||
return lhs.hash < rhs.hash;
|
||||
return hash < rhs.hash;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -121,7 +113,7 @@ public:
|
|||
ostream &operator<<(ostream &os, const State &state);
|
||||
|
||||
|
||||
typedef map<ProtoState, State *, deref_less_than> NodeMap;
|
||||
typedef map<ProtoState, State *> NodeMap;
|
||||
/* Transitions in the DFA. */
|
||||
|
||||
/* dfa_stats - structure to group various stats about dfa creation
|
||||
|
|
Loading…
Add table
Reference in a new issue