AK: Add a fast path for DisjointChunks::spans()

This commit is contained in:
Ali Mohammad Pur 2022-11-03 13:33:14 +03:30 committed by Ali Mohammad Pur
parent 253f4de302
commit e9b9527440
Notes: sideshowbarker 2024-07-17 09:49:48 +09:00

View file

@ -316,6 +316,11 @@ public:
{
Vector<Span<T>, InlineSize> spans;
spans.ensure_capacity(m_chunks.size());
if (m_chunks.size() == 1) {
spans.append(const_cast<ChunkType&>(m_chunks[0]).span());
return DisjointSpans<T, Vector<Span<T>, InlineSize>> { move(spans) };
}
for (auto& chunk : m_chunks)
spans.unchecked_append(const_cast<ChunkType&>(chunk).span());
return DisjointSpans<T, Vector<Span<T>, InlineSize>> { move(spans) };