From c2b20b5681bc6e5459c0a584ad42d9bec0016858 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 16 Nov 2022 01:22:34 +0330 Subject: [PATCH] AK: Give DisjointChunks::m_chunks an inline capacity of 1 That's one fewer level of indirection for flattened ones. --- AK/DisjointChunks.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/AK/DisjointChunks.h b/AK/DisjointChunks.h index 688604a02f..d07d3d8690 100644 --- a/AK/DisjointChunks.h +++ b/AK/DisjointChunks.h @@ -15,11 +15,11 @@ namespace AK { -template +template struct DisjointIterator { struct EndTag { }; - using ReferenceType = Conditional>, Vector>&; + using ReferenceType = Conditional>, Vector>&; DisjointIterator(ReferenceType chunks) : m_chunks(chunks) @@ -232,6 +232,9 @@ FixedArray shatter_chunk(FixedArray& source_chunk, size_t start, size_t sl template> class DisjointChunks { +private: + constexpr static auto InlineCapacity = IsCopyConstructible ? 1 : 0; + public: DisjointChunks() = default; ~DisjointChunks() = default; @@ -397,10 +400,10 @@ public: m_chunks.remove(1, m_chunks.size() - 1); } - DisjointIterator begin() { return { m_chunks }; } - DisjointIterator end() { return { m_chunks, {} }; } - DisjointIterator begin() const { return { m_chunks }; } - DisjointIterator end() const { return { m_chunks, {} }; } + DisjointIterator begin() { return { m_chunks }; } + DisjointIterator end() { return { m_chunks, {} }; } + DisjointIterator begin() const { return { m_chunks }; } + DisjointIterator end() const { return { m_chunks, {} }; } private: struct ChunkAndOffset { @@ -428,7 +431,7 @@ private: return { &m_chunks.last(), index - (offset - m_chunks.last().size()) }; } - Vector m_chunks; + Vector m_chunks; }; }