1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:04:59 +00:00

Kernel: Use a FixedArray for a process's extra GIDs

There's not really enough of these to justify using a HashTable.
This commit is contained in:
Andreas Kling 2020-02-18 10:19:32 +01:00
parent e0ecfc0c92
commit a7dbb3cf96
5 changed files with 42 additions and 12 deletions

View file

@ -54,7 +54,13 @@ public:
new (&m_elements[i]) T(other[i]);
}
FixedArray& operator=(const FixedArray&) = delete;
FixedArray& operator=(const FixedArray& other)
{
FixedArray array(other);
swap(array);
return *this;
}
FixedArray(FixedArray&&) = delete;
FixedArray& operator=(FixedArray&&) = delete;
@ -109,6 +115,21 @@ public:
m_size = new_size;
}
bool contains(const T& value) const
{
for (size_t i = 0; i < m_size; ++i) {
if (m_elements[i] == value)
return true;
}
return false;
}
void swap(FixedArray& other)
{
::swap(m_elements, other.m_elements);
::swap(m_size, other.m_size);
}
using Iterator = VectorIterator<FixedArray, T>;
Iterator begin() { return Iterator(*this, 0); }
Iterator end() { return Iterator(*this, size()); }