[apparmor] [PATCH 06/10] Now that we have a proper class we don't need a functor to do comparisons, we can fold it into the classes operator<.
John Johansen
john.johansen at canonical.com
Fri Oct 28 19:19:33 UTC 2011
Signed-off-by: John Johansen <john.johansen at canonical.com>
---
parser/libapparmor_re/hfa.cc | 2 +-
parser/libapparmor_re/hfa.h | 22 +++++++---------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/parser/libapparmor_re/hfa.cc b/parser/libapparmor_re/hfa.cc
index 516e354..bcfd2de 100644
--- a/parser/libapparmor_re/hfa.cc
+++ b/parser/libapparmor_re/hfa.cc
@@ -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
diff --git a/parser/libapparmor_re/hfa.h b/parser/libapparmor_re/hfa.h
index 82dadf3..29c552f 100644
--- a/parser/libapparmor_re/hfa.h
+++ b/parser/libapparmor_re/hfa.h
@@ -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
--
1.7.5.4
More information about the AppArmor
mailing list