#include <list>
#include "trace_model.hpp"
-
+#include "trace_fast_callset.hpp"
namespace trace {
-
- // Should match Call::no
- typedef unsigned CallNo;
-
-
// Aliases for call flags
enum {
FREQUENCY_NONE = 0,
CallRange limits;
public:
- // TODO: use binary tree to speed up lookups
+ FastCallSet fast_call_set;
+
+ // TODO: use binary tree to speed up lookups, (less important
+ // now that we are using FastCallSet for ranges without step
+ // or freq).
typedef std::list< CallRange > RangeList;
RangeList ranges;
// Not empty set
inline bool
empty() const {
- return ranges.empty();
+ return fast_call_set.empty() && ranges.empty();
}
void
limits.stop = range.stop;
}
- RangeList::iterator it = ranges.begin();
- while (it != ranges.end() && it->start < range.start) {
- ++it;
- }
+ /* Optimize by using fast_call_set whenever possible */
+ if (range.step == 1 && range.freq == FREQUENCY_ALL) {
+ fast_call_set.add(range.start, range.stop);
+ } else {
+ RangeList::iterator it = ranges.begin();
+ while (it != ranges.end() && it->start < range.start) {
+ ++it;
+ }
- ranges.insert(it, range);
+ ranges.insert(it, range);
+ }
}
}
if (empty()) {
return false;
}
+ if (fast_call_set.contains(callNo))
+ return true;
RangeList::const_iterator it;
for (it = ranges.begin(); it != ranges.end() && it->start <= callNo; ++it) {
if (it->contains(callNo, callFlags)) {