mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
report_manager: more use of unordered_map
This commit is contained in:
parent
1878b9a857
commit
9258592d0b
@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -34,9 +34,10 @@
|
|||||||
#ifndef UTIL_REPORT_H
|
#ifndef UTIL_REPORT_H
|
||||||
#define UTIL_REPORT_H
|
#define UTIL_REPORT_H
|
||||||
|
|
||||||
#include "util/exhaust.h" // for INVALID_EKEY
|
|
||||||
#include "order_check.h"
|
|
||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
|
#include "util/exhaust.h" // for INVALID_EKEY
|
||||||
|
#include "util/hash.h"
|
||||||
|
#include "util/order_check.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@ -195,6 +196,23 @@ bool operator<(const Report &a, const Report &b) {
|
|||||||
return false;
|
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
|
static inline
|
||||||
Report makeECallback(u32 report, s32 offsetAdjust, u32 ekey) {
|
Report makeECallback(u32 report, s32 offsetAdjust, u32 ekey) {
|
||||||
Report ir(EXTERNAL_CALLBACK, report);
|
Report ir(EXTERNAL_CALLBACK, report);
|
||||||
|
@ -67,7 +67,7 @@ u32 ReportManager::getInternalId(const Report &ir) {
|
|||||||
|
|
||||||
u32 size = reportIds.size();
|
u32 size = reportIds.size();
|
||||||
reportIds.push_back(ir);
|
reportIds.push_back(ir);
|
||||||
reportIdToInternalMap[ir] = size;
|
reportIdToInternalMap.emplace(ir, size);
|
||||||
DEBUG_PRINTF("new report %u\n", size);
|
DEBUG_PRINTF("new report %u\n", size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -131,13 +131,13 @@ private:
|
|||||||
|
|
||||||
/** \brief Mapping from Report to ID (inverse of \ref reportIds
|
/** \brief Mapping from Report to ID (inverse of \ref reportIds
|
||||||
* vector). */
|
* vector). */
|
||||||
std::map<Report, size_t> reportIdToInternalMap;
|
unordered_map<Report, size_t> reportIdToInternalMap;
|
||||||
|
|
||||||
/** \brief Mapping from ReportID to dedupe key. */
|
/** \brief Mapping from ReportID to dedupe key. */
|
||||||
std::map<ReportID, u32> reportIdToDedupeKey;
|
unordered_map<ReportID, u32> reportIdToDedupeKey;
|
||||||
|
|
||||||
/** \brief Mapping from ReportID to Rose program offset in bytecode. */
|
/** \brief Mapping from ReportID to Rose program offset in bytecode. */
|
||||||
std::map<ReportID, u32> reportIdToProgramOffset;
|
unordered_map<ReportID, u32> reportIdToProgramOffset;
|
||||||
|
|
||||||
/** \brief Mapping from external match ids to information about that
|
/** \brief Mapping from external match ids to information about that
|
||||||
* id. */
|
* id. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user