diff --git a/CHANGES b/CHANGES index 780306f03f..f94b80acfc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +8.0.0-dev.763 | 2025-07-28 13:57:18 -0700 + + * Move ID::type in structure to fill memory padding (Tim Wojtulewicz, Corelight) + + * Use sorted forward_list instead of multimap for ID option change handlers (Tim Wojtulewicz, Corelight) + 8.0.0-dev.760 | 2025-07-28 13:12:47 -0700 * Remove intermediate cipher vectors in ssl-analyzer.pac (Tim Wojtulewicz, Corelight) diff --git a/VERSION b/VERSION index 3aca94f457..fcf92a3f6f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.0-dev.760 +8.0.0-dev.763 diff --git a/src/ID.cc b/src/ID.cc index f666c86cf0..0e2f7575a0 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -576,14 +576,16 @@ void ID::UpdateValID() { } #endif -void ID::AddOptionHandler(FuncPtr callback, int priority) { option_handlers.emplace(priority, std::move(callback)); } +void ID::AddOptionHandler(FuncPtr callback, int priority) { + option_handlers.emplace_front(priority, callback); + option_handlers.sort( + [](const OptionHandler& left, const OptionHandler& right) { return left.first < right.first; }); +} std::vector ID::GetOptionHandlers() const { - // multimap is sorted - // It might be worth caching this if we expect it to be called - // a lot... + // It might be worth caching this if we expect it to be called a lot... std::vector v; - for ( auto& element : option_handlers ) + for ( const auto& element : option_handlers ) v.push_back(element.second.get()); return v; } diff --git a/src/ID.h b/src/ID.h index 41498df005..2d3fc2f057 100644 --- a/src/ID.h +++ b/src/ID.h @@ -2,7 +2,7 @@ #pragma once -#include +#include #include #include #include @@ -157,9 +157,9 @@ protected: #endif const char* name; + TypePtr type; IDScope scope; bool is_export; - TypePtr type; bool is_capture = false; bool is_const = false; bool is_enum_const = false; @@ -172,7 +172,8 @@ protected: AttributesPtr attrs; // contains list of functions that are called when an option changes - std::multimap option_handlers; + using OptionHandler = std::pair; + std::forward_list option_handlers; // Information managed by script optimization. We package this // up into a separate object for purposes of modularity, and,