mirror of
https://github.com/zeek/zeek.git
synced 2025-10-01 22:28:20 +00:00
RecordVal: Use vector32
This reduces the RecordVal size to 64 bytes on 64 bit systems.
This commit is contained in:
parent
df02b989ac
commit
81f4726fc3
2 changed files with 7 additions and 7 deletions
|
@ -2933,7 +2933,7 @@ RecordVal::RecordVal(RecordTypePtr t, bool init_fields) : Val(std::move(t)) {
|
||||||
if ( init_fields ) {
|
if ( init_fields ) {
|
||||||
record_val.resize(rt->NumFields());
|
record_val.resize(rt->NumFields());
|
||||||
|
|
||||||
rt->InitSlots(record_val);
|
rt->InitSlots(std::span{record_val.data(), record_val.size()});
|
||||||
|
|
||||||
for ( auto& e : rt->CreationInits() ) {
|
for ( auto& e : rt->CreationInits() ) {
|
||||||
try {
|
try {
|
||||||
|
@ -2955,11 +2955,10 @@ RecordVal::RecordVal(RecordTypePtr t, bool init_fields) : Val(std::move(t)) {
|
||||||
RecordVal::RecordVal(RecordTypePtr t, std::vector<std::optional<ZVal>> init_vals) : Val(std::move(t)) {
|
RecordVal::RecordVal(RecordTypePtr t, std::vector<std::optional<ZVal>> init_vals) : Val(std::move(t)) {
|
||||||
// TODO: Change so that callers pass init_vals as ZValSlot instead?
|
// TODO: Change so that callers pass init_vals as ZValSlot instead?
|
||||||
size_t n = GetRecordType()->NumFields();
|
size_t n = GetRecordType()->NumFields();
|
||||||
record_val.reserve(n);
|
record_val.resize(n);
|
||||||
|
GetRecordType()->InitSlots(std::span{record_val.data(), record_val.size()});
|
||||||
|
|
||||||
for ( size_t i = 0; i < n; i++ ) {
|
for ( size_t i = 0; i < n; i++ ) {
|
||||||
record_val.emplace_back(ZValSlot(GetRecordType()->GetFieldType(i)));
|
|
||||||
|
|
||||||
if ( init_vals[i].has_value() )
|
if ( init_vals[i].has_value() )
|
||||||
record_val[i] = init_vals[i].value();
|
record_val[i] = init_vals[i].value();
|
||||||
}
|
}
|
||||||
|
@ -3009,6 +3008,7 @@ void RecordVal::ResizeParseTimeRecords(RecordType* revised_rt) {
|
||||||
auto required_length = revised_rt->NumFields();
|
auto required_length = revised_rt->NumFields();
|
||||||
|
|
||||||
if ( required_length > current_length ) {
|
if ( required_length > current_length ) {
|
||||||
|
rv->record_val.reserve(required_length);
|
||||||
for ( auto i = current_length; i < required_length; ++i )
|
for ( auto i = current_length; i < required_length; ++i )
|
||||||
rv->AppendField(revised_rt->FieldDefault(i), revised_rt->GetFieldType(i));
|
rv->AppendField(revised_rt->FieldDefault(i), revised_rt->GetFieldType(i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1656,9 +1656,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
void AppendField(ValPtr v, const TypePtr& t) {
|
void AppendField(ValPtr v, const TypePtr& t) {
|
||||||
if ( v )
|
if ( v )
|
||||||
record_val.emplace_back(ZValSlot(v, t));
|
record_val.push_back(ZValSlot(v, t));
|
||||||
else
|
else
|
||||||
record_val.emplace_back(ZValSlot(t));
|
record_val.push_back(ZValSlot(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For internal use by low-level ZAM instructions and event tracing.
|
// For internal use by low-level ZAM instructions and event tracing.
|
||||||
|
@ -1710,7 +1710,7 @@ private:
|
||||||
// Low-level values of each of the fields.
|
// Low-level values of each of the fields.
|
||||||
//
|
//
|
||||||
// Lazily modified during GetField(), so mutable.
|
// Lazily modified during GetField(), so mutable.
|
||||||
mutable std::vector<ZValSlot> record_val;
|
mutable detail::vector32<ZValSlot> record_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EnumVal final : public detail::IntValImplementation {
|
class EnumVal final : public detail::IntValImplementation {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue