Reformat Zeek in Spicy style

This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
This commit is contained in:
Benjamin Bannier 2023-10-10 21:13:34 +02:00
parent 7b8e7ed72c
commit f5a76c1aed
786 changed files with 131714 additions and 153609 deletions

View file

@ -8,65 +8,51 @@
#include <cstring>
namespace zeek::detail
{
namespace zeek::detail {
class IntSet
{
class IntSet {
public:
// n is a hint for the value of the largest integer.
explicit IntSet(unsigned int n = 1);
~IntSet();
// n is a hint for the value of the largest integer.
explicit IntSet(unsigned int n = 1);
~IntSet();
void Insert(unsigned int i);
void Remove(unsigned int i);
bool Contains(unsigned int i) const;
void Insert(unsigned int i);
void Remove(unsigned int i);
bool Contains(unsigned int i) const;
void Clear();
void Clear();
private:
void Expand(unsigned int i);
void Expand(unsigned int i);
unsigned int size;
unsigned char* set;
};
unsigned int size;
unsigned char* set;
};
inline IntSet::IntSet(unsigned int n)
{
size = n / 8 + 1;
set = new unsigned char[size];
memset(set, 0, size);
}
inline IntSet::IntSet(unsigned int n) {
size = n / 8 + 1;
set = new unsigned char[size];
memset(set, 0, size);
}
inline IntSet::~IntSet()
{
delete[] set;
}
inline IntSet::~IntSet() { delete[] set; }
inline void IntSet::Insert(unsigned int i)
{
if ( i / 8 >= size )
Expand(i);
inline void IntSet::Insert(unsigned int i) {
if ( i / 8 >= size )
Expand(i);
set[i / 8] |= (1 << (i % 8));
}
set[i / 8] |= (1 << (i % 8));
}
inline void IntSet::Remove(unsigned int i)
{
if ( i / 8 >= size )
Expand(i);
else
set[i / 8] &= ~(1 << (i % 8));
}
inline void IntSet::Remove(unsigned int i) {
if ( i / 8 >= size )
Expand(i);
else
set[i / 8] &= ~(1 << (i % 8));
}
inline bool IntSet::Contains(unsigned int i) const
{
return i / 8 < size ? set[i / 8] & (1 << (i % 8)) : false;
}
inline bool IntSet::Contains(unsigned int i) const { return i / 8 < size ? set[i / 8] & (1 << (i % 8)) : false; }
inline void IntSet::Clear()
{
memset(set, 0, size);
}
inline void IntSet::Clear() { memset(set, 0, size); }
} // namespace zeek::detail
} // namespace zeek::detail