AK: Rename Span::subspan() to Span::slice().

This commit is contained in:
asynts 2020-07-27 16:59:49 +02:00 committed by Andreas Kling
parent 8d2dba022e
commit 5fa0fdb219
Notes: sideshowbarker 2024-07-19 04:32:43 +09:00
2 changed files with 8 additions and 8 deletions

View file

@ -144,7 +144,7 @@ public:
ALWAYS_INLINE bool is_empty() const { return this->m_size == 0; }
ALWAYS_INLINE Span<T> subspan(size_t start, size_t size) const
ALWAYS_INLINE Span slice(size_t start, size_t size) const
{
ASSERT(start + size <= this->m_size);
return { this->m_values + start, size };

View file

@ -113,10 +113,10 @@ TEST_CASE(can_subspan_whole_span)
u8 buffer[16];
Bytes bytes { buffer, 16 };
Bytes subspan = bytes.subspan(0, 16);
Bytes slice = bytes.slice(0, 16);
EXPECT_EQ(subspan.data(), buffer);
EXPECT_EQ(subspan.size(), 16u);
EXPECT_EQ(slice.data(), buffer);
EXPECT_EQ(slice.size(), 16u);
}
TEST_CASE(can_subspan_as_intended)
@ -124,11 +124,11 @@ TEST_CASE(can_subspan_as_intended)
const u16 buffer[8] { 1, 2, 3, 4, 5, 6, 7, 8 };
Span<const u16> span { buffer, 8 };
auto subspan = span.subspan(3, 2);
auto slice = span.slice(3, 2);
EXPECT_EQ(subspan.size(), 2u);
EXPECT_EQ(subspan[0], 4);
EXPECT_EQ(subspan[1], 5);
EXPECT_EQ(slice.size(), 2u);
EXPECT_EQ(slice[0], 4);
EXPECT_EQ(slice[1], 5);
}
TEST_CASE(span_from_void_pointer)