libexpr: rename misleading type alias Bindings::size_t
Calling a custom type size_t is incredibly sneaky and makes all the code
around this extremely context dependent.
Change-Id: Idae684781f45fe615020d8642f12a656ab2c15ad
This commit is contained in:
parent
61eed2c97c
commit
9dd58224ea
|
@ -17,11 +17,11 @@ Bindings * EvalMemory::allocBindings(size_t capacity)
|
||||||
{
|
{
|
||||||
if (capacity == 0)
|
if (capacity == 0)
|
||||||
return &Bindings::EMPTY;
|
return &Bindings::EMPTY;
|
||||||
if (capacity > std::numeric_limits<Bindings::size_t>::max())
|
if (capacity > std::numeric_limits<Bindings::Size>::max())
|
||||||
throw Error("attribute set of size %d is too big", capacity);
|
throw Error("attribute set of size %d is too big", capacity);
|
||||||
stats.nrAttrsets++;
|
stats.nrAttrsets++;
|
||||||
stats.nrAttrsInAttrsets += capacity;
|
stats.nrAttrsInAttrsets += capacity;
|
||||||
return new (gcAllocBytes(sizeof(Bindings) + sizeof(Attr) * capacity)) Bindings((Bindings::size_t) capacity);
|
return new (gcAllocBytes(sizeof(Bindings) + sizeof(Attr) * capacity)) Bindings((Bindings::Size) capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,20 +48,20 @@ static_assert(sizeof(Attr) == 2 * sizeof(uint32_t) + sizeof(Value *),
|
||||||
class Bindings
|
class Bindings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef uint32_t size_t;
|
using Size = uint32_t;
|
||||||
PosIdx pos;
|
PosIdx pos;
|
||||||
|
|
||||||
static Bindings EMPTY;
|
static Bindings EMPTY;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t size_, capacity_;
|
Size size_, capacity_;
|
||||||
Attr attrs[0];
|
Attr attrs[0];
|
||||||
|
|
||||||
Bindings(size_t capacity) : size_(0), capacity_(capacity) { }
|
Bindings(Size capacity) : size_(0), capacity_(capacity) { }
|
||||||
Bindings(const Bindings & bindings) = delete;
|
Bindings(const Bindings & bindings) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t size() const { return size_; }
|
Size size() const { return size_; }
|
||||||
|
|
||||||
bool empty() const { return !size_; }
|
bool empty() const { return !size_; }
|
||||||
|
|
||||||
|
@ -92,14 +92,14 @@ public:
|
||||||
iterator begin() { return &attrs[0]; }
|
iterator begin() { return &attrs[0]; }
|
||||||
iterator end() { return &attrs[size_]; }
|
iterator end() { return &attrs[size_]; }
|
||||||
|
|
||||||
Attr & operator[](size_t pos)
|
Attr & operator[](Size pos)
|
||||||
{
|
{
|
||||||
return attrs[pos];
|
return attrs[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
size_t capacity() { return capacity_; }
|
Size capacity() { return capacity_; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the attributes in lexicographically sorted order.
|
* Returns the attributes in lexicographically sorted order.
|
||||||
|
@ -108,7 +108,7 @@ public:
|
||||||
{
|
{
|
||||||
std::vector<const Attr *> res;
|
std::vector<const Attr *> res;
|
||||||
res.reserve(size_);
|
res.reserve(size_);
|
||||||
for (size_t n = 0; n < size_; n++)
|
for (Size n = 0; n < size_; n++)
|
||||||
res.emplace_back(&attrs[n]);
|
res.emplace_back(&attrs[n]);
|
||||||
std::sort(res.begin(), res.end(), [&](const Attr * a, const Attr * b) {
|
std::sort(res.begin(), res.end(), [&](const Attr * a, const Attr * b) {
|
||||||
std::string_view sa = symbols[a->name], sb = symbols[b->name];
|
std::string_view sa = symbols[a->name], sb = symbols[b->name];
|
||||||
|
|
Loading…
Reference in a new issue