mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Use const auto references to avoid some copies
This commit is contained in:
parent
739efc79be
commit
f7495831a2
5 changed files with 8 additions and 8 deletions
|
@ -128,7 +128,7 @@ void CPPCompile::DeclareSubclass(const FuncTypePtr& ft, const ProfileFunc* pf, c
|
||||||
|
|
||||||
if ( lambda_ids ) {
|
if ( lambda_ids ) {
|
||||||
for ( auto& id : *lambda_ids ) {
|
for ( auto& id : *lambda_ids ) {
|
||||||
auto name = lambda_names[id];
|
const auto& name = lambda_names[id];
|
||||||
auto tn = FullTypeName(id->GetType());
|
auto tn = FullTypeName(id->GetType());
|
||||||
addl_args = addl_args + ", " + tn + " _" + name;
|
addl_args = addl_args + ", " + tn + " _" + name;
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ void CPPCompile::BuildLambda(const FuncTypePtr& ft, const ProfileFunc* pf, const
|
||||||
const LambdaExpr* l, const IDPList* lambda_ids) {
|
const LambdaExpr* l, const IDPList* lambda_ids) {
|
||||||
// Declare the member variables for holding the captures.
|
// Declare the member variables for holding the captures.
|
||||||
for ( auto& id : *lambda_ids ) {
|
for ( auto& id : *lambda_ids ) {
|
||||||
auto name = lambda_names[id];
|
const auto& name = lambda_names[id];
|
||||||
auto tn = FullTypeName(id->GetType());
|
auto tn = FullTypeName(id->GetType());
|
||||||
Emit("%s %s;", tn, name);
|
Emit("%s %s;", tn, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1053,13 +1053,13 @@ string CPPCompile::GenDirectAssign(const ExprPtr& lhs, const string& rhs_native,
|
||||||
if ( n->IsBlank() )
|
if ( n->IsBlank() )
|
||||||
return rhs_native;
|
return rhs_native;
|
||||||
|
|
||||||
auto name = IDNameStr(n);
|
const auto& name = IDNameStr(n);
|
||||||
|
|
||||||
string gen;
|
string gen;
|
||||||
|
|
||||||
if ( n->IsGlobal() ) {
|
if ( n->IsGlobal() ) {
|
||||||
const auto& t = n->GetType();
|
const auto& t = n->GetType();
|
||||||
auto gn = globals[n->Name()];
|
const auto& gn = globals[n->Name()];
|
||||||
|
|
||||||
if ( t->Tag() == TYPE_FUNC && t->AsFuncType()->Flavor() == FUNC_FLAVOR_EVENT ) {
|
if ( t->Tag() == TYPE_FUNC && t->AsFuncType()->Flavor() == FUNC_FLAVOR_EVENT ) {
|
||||||
gen = string("set_event__CPP(") + gn + ", " + rhs_val_ptr + ", " + gn + "_ev)";
|
gen = string("set_event__CPP(") + gn + ", " + rhs_val_ptr + ", " + gn + "_ev)";
|
||||||
|
|
|
@ -320,7 +320,7 @@ void CPPCompile::GenWhenStmt(const WhenInfo* wi, const std::string& when_lambda,
|
||||||
vector<string> local_aggrs) {
|
vector<string> local_aggrs) {
|
||||||
auto is_return = wi->IsReturn() ? "true" : "false";
|
auto is_return = wi->IsReturn() ? "true" : "false";
|
||||||
auto timeout = wi->TimeoutExpr();
|
auto timeout = wi->TimeoutExpr();
|
||||||
auto timeout_val = timeout ? GenExpr(timeout, GEN_NATIVE) : "-1.0";
|
const auto& timeout_val = timeout ? GenExpr(timeout, GEN_NATIVE) : "-1.0";
|
||||||
|
|
||||||
Emit("{ // begin a new scope for internal variables");
|
Emit("{ // begin a new scope for internal variables");
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ static void analyze_scripts_for_ZAM(std::shared_ptr<ProfileFuncs> pfs) {
|
||||||
if ( g->GetType()->Tag() != TYPE_FUNC )
|
if ( g->GetType()->Tag() != TYPE_FUNC )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto v = g->GetVal();
|
const auto& v = g->GetVal();
|
||||||
if ( v )
|
if ( v )
|
||||||
func_used_indirectly.insert(v->AsFunc());
|
func_used_indirectly.insert(v->AsFunc());
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,8 +941,8 @@ const ZAMStmt ZAMCompiler::CompileReturn(const ReturnStmt* r) {
|
||||||
const ZAMStmt ZAMCompiler::CompileCatchReturn(const CatchReturnStmt* cr) {
|
const ZAMStmt ZAMCompiler::CompileCatchReturn(const CatchReturnStmt* cr) {
|
||||||
retvars.push_back(cr->RetVar());
|
retvars.push_back(cr->RetVar());
|
||||||
|
|
||||||
auto hold_func = ZAM::curr_func;
|
const auto& hold_func = ZAM::curr_func;
|
||||||
auto hold_loc = ZAM::curr_loc;
|
const auto& hold_loc = ZAM::curr_loc;
|
||||||
|
|
||||||
ZAM::curr_func = cr->Func()->GetName();
|
ZAM::curr_func = cr->Func()->GetName();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue