diff --git a/src/util/report.h b/src/util/report.h index 24ecca9d..a8e233ff 100644 --- a/src/util/report.h +++ b/src/util/report.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,9 +34,10 @@ #ifndef UTIL_REPORT_H #define UTIL_REPORT_H -#include "util/exhaust.h" // for INVALID_EKEY -#include "order_check.h" #include "ue2common.h" +#include "util/exhaust.h" // for INVALID_EKEY +#include "util/hash.h" +#include "util/order_check.h" #include @@ -195,6 +196,23 @@ bool operator<(const Report &a, const Report &b) { return false; } +inline +bool operator==(const Report &a, const Report &b) { + return a.type == b.type && a.quashSom == b.quashSom && + a.minOffset == b.minOffset && a.maxOffset == b.maxOffset && + a.minLength == b.minLength && a.ekey == b.ekey && + a.offsetAdjust == b.offsetAdjust && a.onmatch == b.onmatch && + a.revNfaIndex == b.revNfaIndex && a.somDistance == b.somDistance && + a.topSquashDistance == b.topSquashDistance; +} + +inline +size_t hash_value(const Report &r) { + return hash_all(r.type, r.quashSom, r.minOffset, r.maxOffset, r.minLength, + r.ekey, r.offsetAdjust, r.onmatch, r.revNfaIndex, + r.somDistance, r.topSquashDistance); +} + static inline Report makeECallback(u32 report, s32 offsetAdjust, u32 ekey) { Report ir(EXTERNAL_CALLBACK, report); diff --git a/src/util/report_manager.cpp b/src/util/report_manager.cpp index 6f6bd0e8..a846eb25 100644 --- a/src/util/report_manager.cpp +++ b/src/util/report_manager.cpp @@ -67,7 +67,7 @@ u32 ReportManager::getInternalId(const Report &ir) { u32 size = reportIds.size(); reportIds.push_back(ir); - reportIdToInternalMap[ir] = size; + reportIdToInternalMap.emplace(ir, size); DEBUG_PRINTF("new report %u\n", size); return size; } diff --git a/src/util/report_manager.h b/src/util/report_manager.h index 3fcad330..95e14a2c 100644 --- a/src/util/report_manager.h +++ b/src/util/report_manager.h @@ -130,14 +130,14 @@ private: std::vector reportIds; /** \brief Mapping from Report to ID (inverse of \ref reportIds - * vector). */ - std::map reportIdToInternalMap; + * vector). */ + unordered_map reportIdToInternalMap; /** \brief Mapping from ReportID to dedupe key. */ - std::map reportIdToDedupeKey; + unordered_map reportIdToDedupeKey; /** \brief Mapping from ReportID to Rose program offset in bytecode. */ - std::map reportIdToProgramOffset; + unordered_map reportIdToProgramOffset; /** \brief Mapping from external match ids to information about that * id. */