UID, ..: un-inline methods to reduce header dependencies

Only 1% build time speedup, but still, it declutters the headers a bit.

Before this patch:

 2565.17user 141.83system 2:25.46elapsed 1860%CPU (0avgtext+0avgdata 1489076maxresident)k
 72576inputs+9130920outputs (1667major+49400430minor)pagefaults 0swaps

After this patch:

 2537.19user 142.94system 2:26.90elapsed 1824%CPU (0avgtext+0avgdata 1434268maxresident)k
 16240inputs+8887152outputs (1931major+48728888minor)pagefaults 0swaps
This commit is contained in:
Max Kellermann 2020-02-02 16:29:27 +01:00
parent 0db61f3094
commit 6a815b4b06
38 changed files with 348 additions and 211 deletions

View file

@ -5,7 +5,9 @@
#include <vector>
#include "IPAddr.h"
#include "Reporter.h"
#include "BroString.h"
#include "Conn.h"
#include "Hash.h"
#include "bro_inet_ntop.h"
#include "analyzer/Manager.h"
@ -45,6 +47,16 @@ ConnIDKey BuildConnIDKey(const ConnID& id)
return key;
}
IPAddr::IPAddr(const BroString& s)
{
Init(s.CheckString());
}
HashKey* IPAddr::GetHashKey() const
{
return new HashKey((void*)in6.s6_addr, sizeof(in6.s6_addr));
}
static inline uint32_t bit_mask32(int bottom_bits)
{
if ( bottom_bits >= 32 )
@ -290,6 +302,19 @@ string IPPrefix::AsString() const
return prefix.AsString() +"/" + l;
}
HashKey* IPPrefix::GetHashKey() const
{
struct {
in6_addr ip;
uint32_t len;
} key;
key.ip = prefix.in6;
key.len = Length();
return new HashKey(&key, sizeof(key));
}
bool IPPrefix::ConvertString(const char* text, IPPrefix* result)
{
string s(text);