Preallocate all possible PortVals.

The performance benefit is small (maybe ~1% at most), however, it's a
trivial change without downsides.
This commit is contained in:
Jon Siwek 2017-12-11 15:29:28 -06:00
parent 895e7b06b1
commit 1e4964de77
29 changed files with 139 additions and 68 deletions

View file

@ -33,13 +33,13 @@ static Val* parse_port(const char* line)
}
r->Assign(0, new AddrVal(htonl(addr)));
r->Assign(1, new PortVal(port, TRANSPORT_TCP));
r->Assign(1, port_mgr->Get(port, TRANSPORT_TCP));
r->Assign(2, new Val(good, TYPE_BOOL));
}
else
{
r->Assign(0, new AddrVal(uint32(0)));
r->Assign(1, new PortVal(0, TRANSPORT_TCP));
r->Assign(1, port_mgr->Get(0, TRANSPORT_TCP));
r->Assign(2, new Val(0, TYPE_BOOL));
}
@ -109,7 +109,7 @@ static Val* parse_eftp(const char* line)
}
r->Assign(0, new AddrVal(addr));
r->Assign(1, new PortVal(port, TRANSPORT_TCP));
r->Assign(1, port_mgr->Get(port, TRANSPORT_TCP));
r->Assign(2, new Val(good, TYPE_BOOL));
return r;