unsigned Signature::hash() const { uint32_t sizeToHash = allocatedSize(argumentCount()) / sizeof(allocationSizeRoundsUpTo); // Assumes over-allocated memory was zero-initialized, and rounded-up to allocationSizeRoundsUpTo so that a wider hash can be performed. ASSERT(sizeToHash * sizeof(allocationSizeRoundsUpTo) == allocatedSize(argumentCount())); unsigned accumulator = 0xa1bcedd8u; const auto* pos = reinterpret_cast<const allocationSizeRoundsUpTo*>(this); for (uint32_t i = 0; i < sizeToHash; ++i) accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<allocationSizeRoundsUpTo>::hash(*pos)); return accumulator; }
void MOchman::Vector<Type>::push_back(const Vector<Type>& vec) { if(size() + vec.size() > allocatedSize()) reserve(size() + vec.size()); std::copy(vec.m_data, vec.m_data + vec.size(), m_data + size()); m_size += vec.size(); }
Signature* Signature::create(SignatureArgCount argumentCount) { // Hashing relies on allocation zero-initializing trailing elements. auto allocated = tryFastCalloc(allocatedSize(argumentCount), 1); Signature* signature; if (!allocated.getValue(signature)) return nullptr; new (signature) Signature(argumentCount); return signature; }
void MOchman::Vector<Type>::push_back(Type element) { if(size() == allocatedSize()) { reserve(size() + 1); m_data[size()] = element; m_size += 1; delete[] m_data; } else { m_size += 1; m_data[size() - 1] = element; } }