Merge remote-tracking branch 'origin/topic/neverlord/data-to-threading-field'

* origin/topic/neverlord/data-to-threading-field:
  Avoid extra copies in threading_field_to_data
This commit is contained in:
Johanna Amann 2024-01-03 09:38:17 +00:00
commit df37cadbe8
4 changed files with 17 additions and 4 deletions

View file

@ -1,3 +1,12 @@
6.2.0-dev.305 | 2024-01-03 09:38:17 +0000
* Avoid extra copies in threading_field_to_data (Dominik Charousset)
Passing the `broker::data` paramter for `threading_field_to_data` by
value forces copies. However, the function only needs const access to
its parameter. Hence, taking the parameter as const-ref is the logical
choice and avoids unnecessary copies of individual data fields.
6.2.0-dev.302 | 2024-01-02 11:13:17 -0700
* smb: Fix &read_expire not in effect due to &default=string_set() usage (Arne Welzel, Corelight)

View file

@ -1 +1 @@
6.2.0-dev.302
6.2.0-dev.305

View file

@ -1154,13 +1154,17 @@ broker::data threading_field_to_data(const threading::Field* f) {
return broker::vector({name, secondary, type, subtype, optional});
}
threading::Field* data_to_threading_field(broker::data d) {
threading::Field* data_to_threading_field(const broker::data& d) {
if ( ! holds_alternative<broker::vector>(d) )
return nullptr;
auto& v = get<broker::vector>(d);
if ( v.size() < 5 )
return nullptr;
auto name = get_if<std::string>(&v[0]);
auto secondary = v[1];
const auto& secondary = v[1];
auto type = get_if<broker::count>(&v[2]);
auto subtype = get_if<broker::count>(&v[3]);
auto optional = get_if<broker::boolean>(&v[4]);

View file

@ -101,7 +101,7 @@ broker::data threading_field_to_data(const threading::Field* f);
* @return a pointer to a new zeek::threading::Value or a nullptr if the conversion was not
* possible.
*/
threading::Field* data_to_threading_field(broker::data d);
threading::Field* data_to_threading_field(const broker::data& d);
/**
* A Zeek value which wraps a Broker data value.