mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
AK: Add a fast path for DisjointChunks::spans()
This commit is contained in:
parent
253f4de302
commit
e9b9527440
1 changed files with 5 additions and 0 deletions
|
@ -316,6 +316,11 @@ public:
|
||||||
{
|
{
|
||||||
Vector<Span<T>, InlineSize> spans;
|
Vector<Span<T>, InlineSize> spans;
|
||||||
spans.ensure_capacity(m_chunks.size());
|
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)
|
for (auto& chunk : m_chunks)
|
||||||
spans.unchecked_append(const_cast<ChunkType&>(chunk).span());
|
spans.unchecked_append(const_cast<ChunkType&>(chunk).span());
|
||||||
return DisjointSpans<T, Vector<Span<T>, InlineSize>> { move(spans) };
|
return DisjointSpans<T, Vector<Span<T>, InlineSize>> { move(spans) };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue