remove use of template in initializer

This commit is contained in:
Vern Paxson 2024-08-09 16:05:36 -07:00
parent 371dcdc94e
commit dcc917a1bf
2 changed files with 8 additions and 3 deletions

View file

@ -166,7 +166,7 @@ void CPPCompile::InitializeConsts() {
StartBlock();
for ( const auto& c : consts )
Emit("CPP_ValElem(%s, %s),", TypeTagName(c.first), Fmt(c.second));
Emit("{%s, %s},", TypeTagName(c.first), Fmt(c.second));
EndBlock(true);
}

View file

@ -29,7 +29,12 @@ public:
};
// Convenient way to refer to an offset associated with a particular Zeek type.
using CPP_ValElem = std::pair<TypeTag, int>;
// A "struct" rather than a std::pair because C++ compilers are terribly slow
// at initializing large numbers of the latter.
struct CPP_ValElem {
TypeTag tag;
int offset;
};
// This class groups together all of the vectors needed for run-time
// initialization. We gather them together into a single object so as
@ -57,7 +62,7 @@ public:
// index.
ValPtr ConstVals(int offset) const {
auto& cv = const_vals[offset];
return Consts(cv.first, cv.second);
return Consts(cv.tag, cv.offset);
}
// Retrieves the Zeek constant value for a particular Zeek type.