From 63b11030f03e5a0fd06d9c8cfa788da0388096d8 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 5 Feb 2023 19:02:54 +0000 Subject: [PATCH] Everywhere: Use ReadonlySpan instead of Span --- AK/Array.h | 4 ++-- AK/ByteBuffer.h | 4 ++-- AK/FixedArray.h | 2 +- AK/Format.h | 18 +++++++++--------- AK/MemMem.h | 4 ++-- AK/Span.h | 4 ++-- AK/UFixedBigInt.h | 8 ++++---- AK/Utf16View.h | 4 ++-- AK/Vector.h | 6 +++--- Kernel/Credentials.cpp | 2 +- Kernel/Credentials.h | 4 ++-- Kernel/FileSystem/InodeMetadata.h | 6 +++--- Kernel/Interrupts/GenericInterruptHandler.cpp | 2 +- Kernel/Interrupts/GenericInterruptHandler.h | 2 +- Kernel/Memory/SharedFramebufferVMObject.cpp | 6 +++--- Kernel/Memory/SharedFramebufferVMObject.h | 10 +++++----- Kernel/Memory/VMObject.h | 2 +- Ladybird/HelperProcess.cpp | 2 +- Ladybird/HelperProcess.h | 2 +- .../LibLocale/GenerateDateTimeFormatData.cpp | 4 ++-- .../LibLocale/GenerateLocaleData.cpp | 4 ++-- .../LibLocale/GenerateNumberFormatData.cpp | 2 +- .../LibLocale/GeneratePluralRulesData.cpp | 2 +- .../LibTimeZone/GenerateTimeZoneData.cpp | 2 +- .../LibUnicode/GenerateEmojiData.cpp | 6 +++--- .../LibUnicode/GenerateUnicodeData.cpp | 18 +++++++++--------- .../CodeGenerators/LibUnicode/GeneratorUtil.h | 8 ++++---- Tests/AK/TestArray.cpp | 2 +- Tests/AK/TestSpan.cpp | 2 +- Userland/Applications/Browser/CookieJar.cpp | 2 +- Userland/Applications/Browser/Database.h | 2 +- .../ClockSettings/TimeZoneSettingsWidget.cpp | 2 +- .../Applications/HexEditor/HexEditorWidget.cpp | 2 +- Userland/Games/2048/Game.cpp | 2 +- Userland/Libraries/LibAudio/MP3HuffmanTables.h | 4 ++-- Userland/Libraries/LibAudio/MP3Loader.cpp | 8 ++++---- Userland/Libraries/LibAudio/MP3Loader.h | 2 +- Userland/Libraries/LibCore/ArgsParser.cpp | 4 ++-- Userland/Libraries/LibCore/ArgsParser.h | 2 +- Userland/Libraries/LibCore/Process.cpp | 6 +++--- Userland/Libraries/LibCore/Process.h | 6 +++--- Userland/Libraries/LibCore/System.cpp | 4 ++-- Userland/Libraries/LibCore/System.h | 6 +++--- Userland/Libraries/LibDSP/Clip.h | 2 +- Userland/Libraries/LibDSP/MDCT.h | 2 +- Userland/Libraries/LibDSP/Track.h | 2 +- Userland/Libraries/LibDesktop/AppFile.cpp | 2 +- Userland/Libraries/LibGUI/Process.cpp | 8 ++++---- Userland/Libraries/LibGUI/Process.h | 6 +++--- Userland/Libraries/LibGfx/Font/Emoji.cpp | 2 +- Userland/Libraries/LibGfx/Font/Emoji.h | 2 +- .../Libraries/LibGfx/Font/OpenType/Font.cpp | 2 +- Userland/Libraries/LibGfx/GradientPainting.cpp | 16 ++++++++-------- Userland/Libraries/LibGfx/PaintStyle.h | 2 +- Userland/Libraries/LibGfx/Painter.cpp | 2 +- Userland/Libraries/LibGfx/Painter.h | 8 ++++---- Userland/Libraries/LibJS/AST.cpp | 6 +++--- Userland/Libraries/LibJS/AST.h | 14 +++++++------- .../Libraries/LibJS/Bytecode/ASTCodegen.cpp | 2 +- Userland/Libraries/LibJS/Bytecode/Op.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Array.h | 4 ++-- .../LibJS/Runtime/DeclarativeEnvironment.cpp | 2 +- .../LibJS/Runtime/DeclarativeEnvironment.h | 2 +- .../LibJS/Runtime/Intl/AbstractOperations.cpp | 4 ++-- .../LibJS/Runtime/Intl/AbstractOperations.h | 6 +++--- .../LibJS/Runtime/Intl/DateTimeFormat.cpp | 2 +- .../LibJS/Runtime/Intl/DateTimeFormat.h | 2 +- .../LibJS/Runtime/Intl/DurationFormat.cpp | 2 +- .../LibJS/Runtime/Intl/DurationFormat.h | 4 ++-- Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp | 2 +- .../LibJS/Runtime/Intl/LocaleConstructor.cpp | 4 ++-- .../Runtime/Temporal/AbstractOperations.cpp | 2 +- .../Runtime/Temporal/AbstractOperations.h | 4 ++-- .../LibJS/Runtime/Temporal/Calendar.cpp | 2 +- .../LibJS/Runtime/Temporal/Calendar.h | 2 +- Userland/Libraries/LibJS/Runtime/TypedArray.h | 2 +- Userland/Libraries/LibLocale/Locale.cpp | 16 ++++++++-------- Userland/Libraries/LibLocale/Locale.h | 16 ++++++++-------- Userland/Libraries/LibLocale/NumberFormat.cpp | 2 +- Userland/Libraries/LibLocale/NumberFormat.h | 2 +- Userland/Libraries/LibLocale/PluralRules.cpp | 2 +- Userland/Libraries/LibLocale/PluralRules.h | 2 +- Userland/Libraries/LibPDF/DocumentParser.cpp | 2 +- Userland/Libraries/LibSQL/AST/AST.h | 4 ++-- Userland/Libraries/LibSQL/AST/Statement.cpp | 2 +- Userland/Libraries/LibTimeZone/TimeZone.cpp | 2 +- Userland/Libraries/LibTimeZone/TimeZone.h | 2 +- .../Libraries/LibUnicode/CharacterTypes.cpp | 2 +- Userland/Libraries/LibUnicode/CharacterTypes.h | 2 +- Userland/Libraries/LibUnicode/Emoji.cpp | 2 +- Userland/Libraries/LibUnicode/Emoji.h | 6 +++--- .../Libraries/LibVT/EscapeSequenceParser.h | 8 ++++---- Userland/Libraries/LibWeb/CSS/BackdropFilter.h | 2 +- .../LibWeb/Painting/FilterPainting.cpp | 2 +- .../Libraries/LibWeb/Painting/FilterPainting.h | 2 +- .../Libraries/LibWeb/SVG/SVGPathElement.cpp | 2 +- Userland/Libraries/LibWeb/SVG/SVGPathElement.h | 2 +- Userland/Libraries/LibWeb/WebDriver/Client.h | 2 +- .../WindowServer/HardwareScreenBackend.cpp | 2 +- .../WindowServer/HardwareScreenBackend.h | 2 +- Userland/Services/WindowServer/ScreenBackend.h | 2 +- .../WindowServer/VirtualScreenBackend.h | 2 +- 102 files changed, 206 insertions(+), 206 deletions(-) diff --git a/AK/Array.h b/AK/Array.h index a12949cad2..26c0a225b5 100644 --- a/AK/Array.h +++ b/AK/Array.h @@ -31,7 +31,7 @@ struct Array { [[nodiscard]] constexpr size_t size() const { return Size; } - [[nodiscard]] constexpr Span span() const { return { __data, Size }; } + [[nodiscard]] constexpr ReadonlySpan span() const { return { __data, Size }; } [[nodiscard]] constexpr Span span() { return { __data, Size }; } [[nodiscard]] constexpr T const& at(size_t index) const @@ -76,7 +76,7 @@ struct Array { [[nodiscard]] constexpr ConstIterator end() const { return ConstIterator::end(*this); } [[nodiscard]] constexpr Iterator end() { return Iterator::end(*this); } - [[nodiscard]] constexpr operator Span() const { return span(); } + [[nodiscard]] constexpr operator ReadonlySpan() const { return span(); } [[nodiscard]] constexpr operator Span() { return span(); } constexpr size_t fill(T const& value) diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index f7f54239e7..7f24872cad 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -123,8 +123,8 @@ public: [[nodiscard]] Bytes bytes() { return { data(), size() }; } [[nodiscard]] ReadonlyBytes bytes() const { return { data(), size() }; } - [[nodiscard]] AK::Span span() { return { data(), size() }; } - [[nodiscard]] AK::Span span() const { return { data(), size() }; } + [[nodiscard]] AK::Bytes span() { return { data(), size() }; } + [[nodiscard]] AK::ReadonlyBytes span() const { return { data(), size() }; } [[nodiscard]] u8* offset_pointer(size_t offset) { return data() + offset; } [[nodiscard]] u8 const* offset_pointer(size_t offset) const { return data() + offset; } diff --git a/AK/FixedArray.h b/AK/FixedArray.h index a12fbd973e..0eb8a22c74 100644 --- a/AK/FixedArray.h +++ b/AK/FixedArray.h @@ -163,7 +163,7 @@ public: ConstIterator end() const { return ConstIterator::end(*this); } Span span() { return { data(), size() }; } - Span span() const { return { data(), size() }; } + ReadonlySpan span() const { return { data(), size() }; } private: struct Storage { diff --git a/AK/Format.h b/AK/Format.h index 6f9ffe1d9b..c86412c556 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -264,13 +264,13 @@ private: class TypeErasedFormatParams { public: - Span parameters() const { return m_parameters; } + ReadonlySpan parameters() const { return m_parameters; } - void set_parameters(Span parameters) { m_parameters = parameters; } + void set_parameters(ReadonlySpan parameters) { m_parameters = parameters; } size_t take_next_index() { return m_next_index++; } private: - Span m_parameters; + ReadonlySpan m_parameters; size_t m_next_index { 0 }; }; @@ -359,14 +359,14 @@ struct Formatter : StandardFormatter { template requires(HasFormatter) -struct Formatter> : StandardFormatter { +struct Formatter> : StandardFormatter { Formatter() = default; explicit Formatter(StandardFormatter formatter) : StandardFormatter(move(formatter)) { } - ErrorOr format(FormatBuilder& builder, Span value) + ErrorOr format(FormatBuilder& builder, ReadonlySpan value) { if (m_mode == Mode::Pointer) { Formatter formatter { *this }; @@ -406,19 +406,19 @@ struct Formatter> : StandardFormatter { template requires(HasFormatter) -struct Formatter> : Formatter> { +struct Formatter> : Formatter> { ErrorOr format(FormatBuilder& builder, Span value) { - return Formatter>::format(builder, value); + return Formatter>::format(builder, value); } }; template requires(HasFormatter) -struct Formatter> : Formatter> { +struct Formatter> : Formatter> { ErrorOr format(FormatBuilder& builder, Vector const& value) { - return Formatter>::format(builder, value.span()); + return Formatter>::format(builder, value.span()); } }; diff --git a/AK/MemMem.h b/AK/MemMem.h index 1d36550f09..3853858d48 100644 --- a/AK/MemMem.h +++ b/AK/MemMem.h @@ -43,7 +43,7 @@ constexpr void const* bitap_bitwise(void const* haystack, size_t haystack_length } template -inline Optional memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, Span needle) +inline Optional memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, ReadonlyBytes needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) { auto prepare_kmp_partial_table = [&] { @@ -123,7 +123,7 @@ inline Optional memmem_optional(void const* haystack, size_t haystack_le } // Fallback to KMP. - Array, 1> spans { Span { (u8 const*)haystack, haystack_length } }; + Array spans { ReadonlyBytes { (u8 const*)haystack, haystack_length } }; return memmem(spans.begin(), spans.end(), { (u8 const*)needle, needle_length }); } diff --git a/AK/Span.h b/AK/Span.h index c4ffe3c9b5..4399dcc136 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -192,7 +192,7 @@ public: return false; } - [[nodiscard]] bool constexpr starts_with(Span other) const + [[nodiscard]] bool constexpr starts_with(ReadonlySpan other) const { if (size() < other.size()) return false; @@ -250,7 +250,7 @@ public: return TypedTransfer::compare(data(), other.data(), size()); } - ALWAYS_INLINE constexpr operator Span() const + ALWAYS_INLINE constexpr operator ReadonlySpan() const { return { data(), size() }; } diff --git a/AK/UFixedBigInt.h b/AK/UFixedBigInt.h index 2066c8376a..a13135137b 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -77,13 +77,13 @@ public: return m_high; } - Span bytes() + Bytes bytes() { - return Span(reinterpret_cast(this), sizeof(R)); + return Bytes { reinterpret_cast(this), sizeof(R) }; } - Span bytes() const + ReadonlyBytes bytes() const { - return Span(reinterpret_cast(this), sizeof(R)); + return ReadonlyBytes { reinterpret_cast(this), sizeof(R) }; } template diff --git a/AK/Utf16View.h b/AK/Utf16View.h index 2e8cd31d7f..ff7c23740a 100644 --- a/AK/Utf16View.h +++ b/AK/Utf16View.h @@ -64,7 +64,7 @@ public: Utf16View() = default; ~Utf16View() = default; - explicit Utf16View(Span code_units) + explicit Utf16View(ReadonlySpan code_units) : m_code_units(code_units) { } @@ -116,7 +116,7 @@ private: size_t calculate_length_in_code_points() const; - Span m_code_units; + ReadonlySpan m_code_units; mutable Optional m_length_in_code_points; }; diff --git a/AK/Vector.h b/AK/Vector.h index e0fce22193..35f7fb2f56 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -90,7 +90,7 @@ public: m_size = other.size(); } - explicit Vector(Span other) + explicit Vector(ReadonlySpan other) requires(!IsLvalueReference) { ensure_capacity(other.size()); @@ -112,10 +112,10 @@ public: } Span span() { return { data(), size() }; } - Span span() const { return { data(), size() }; } + ReadonlySpan span() const { return { data(), size() }; } operator Span() { return span(); } - operator Span() const { return span(); } + operator ReadonlySpan() const { return span(); } bool is_empty() const { return size() == 0; } ALWAYS_INLINE size_t size() const { return m_size; } diff --git a/Kernel/Credentials.cpp b/Kernel/Credentials.cpp index ba97a34be2..bea6dd2570 100644 --- a/Kernel/Credentials.cpp +++ b/Kernel/Credentials.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr> Credentials::create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, Span extra_gids, SessionID sid, ProcessGroupID pgid) +ErrorOr> Credentials::create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, ReadonlySpan extra_gids, SessionID sid, ProcessGroupID pgid) { auto extra_gids_array = TRY(FixedArray::create(extra_gids)); return adopt_nonnull_ref_or_enomem(new (nothrow) Credentials(uid, gid, euid, egid, suid, sgid, move(extra_gids_array), sid, pgid)); diff --git a/Kernel/Credentials.h b/Kernel/Credentials.h index 25e002a25e..cc6b88052d 100644 --- a/Kernel/Credentials.h +++ b/Kernel/Credentials.h @@ -14,7 +14,7 @@ namespace Kernel { class Credentials final : public AtomicRefCounted { public: - static ErrorOr> create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, Span extra_gids, SessionID sid, ProcessGroupID pgid); + static ErrorOr> create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, ReadonlySpan extra_gids, SessionID sid, ProcessGroupID pgid); ~Credentials(); bool is_superuser() const { return euid() == 0; } @@ -25,7 +25,7 @@ public: GroupID gid() const { return m_gid; } UserID suid() const { return m_suid; } GroupID sgid() const { return m_sgid; } - Span extra_gids() const { return m_extra_gids.span(); } + ReadonlySpan extra_gids() const { return m_extra_gids.span(); } SessionID sid() const { return m_sid; }; ProcessGroupID pgid() const { return m_pgid; } diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h index 0d1967141a..e6300f6146 100644 --- a/Kernel/FileSystem/InodeMetadata.h +++ b/Kernel/FileSystem/InodeMetadata.h @@ -48,7 +48,7 @@ struct InodeMetadata { bool may_write(Credentials const&, UseEffectiveIDs = UseEffectiveIDs::Yes) const; bool may_execute(Credentials const&, UseEffectiveIDs = UseEffectiveIDs::Yes) const; - bool may_read(UserID u, GroupID g, Span eg) const + bool may_read(UserID u, GroupID g, ReadonlySpan eg) const { if (u == 0) return true; @@ -59,7 +59,7 @@ struct InodeMetadata { return (mode & S_IROTH) == S_IROTH; } - bool may_write(UserID u, GroupID g, Span eg) const + bool may_write(UserID u, GroupID g, ReadonlySpan eg) const { if (u == 0) return true; @@ -70,7 +70,7 @@ struct InodeMetadata { return (mode & S_IWOTH) == S_IWOTH; } - bool may_execute(UserID u, GroupID g, Span eg) const + bool may_execute(UserID u, GroupID g, ReadonlySpan eg) const { if (u == 0) return true; diff --git a/Kernel/Interrupts/GenericInterruptHandler.cpp b/Kernel/Interrupts/GenericInterruptHandler.cpp index 9cc2e65535..8e618ec1ff 100644 --- a/Kernel/Interrupts/GenericInterruptHandler.cpp +++ b/Kernel/Interrupts/GenericInterruptHandler.cpp @@ -67,7 +67,7 @@ void GenericInterruptHandler::change_interrupt_number(u8 number) register_generic_interrupt_handler(InterruptManagement::acquire_mapped_interrupt_number(interrupt_number()), *this); } -Span GenericInterruptHandler::per_cpu_call_counts() const +ReadonlySpan GenericInterruptHandler::per_cpu_call_counts() const { return m_per_cpu_call_counts.span().slice(0, Processor::count()); } diff --git a/Kernel/Interrupts/GenericInterruptHandler.h b/Kernel/Interrupts/GenericInterruptHandler.h index 5d512c08a2..ea1f648313 100644 --- a/Kernel/Interrupts/GenericInterruptHandler.h +++ b/Kernel/Interrupts/GenericInterruptHandler.h @@ -37,7 +37,7 @@ public: u8 interrupt_number() const { return m_interrupt_number; } - Span per_cpu_call_counts() const; + ReadonlySpan per_cpu_call_counts() const; virtual size_t sharing_devices_count() const = 0; virtual bool is_shared_handler() const = 0; diff --git a/Kernel/Memory/SharedFramebufferVMObject.cpp b/Kernel/Memory/SharedFramebufferVMObject.cpp index d9401aa48e..ba34f72952 100644 --- a/Kernel/Memory/SharedFramebufferVMObject.cpp +++ b/Kernel/Memory/SharedFramebufferVMObject.cpp @@ -60,7 +60,7 @@ Span> SharedFramebufferVMObject::real_framebuffer_physical_ { return m_real_framebuffer_vmobject->physical_pages(); } -Span const> SharedFramebufferVMObject::real_framebuffer_physical_pages() const +ReadonlySpan> SharedFramebufferVMObject::real_framebuffer_physical_pages() const { return m_real_framebuffer_vmobject->physical_pages(); } @@ -70,7 +70,7 @@ Span> SharedFramebufferVMObject::fake_sink_framebuffer_phys return m_physical_pages.span(); } -Span const> SharedFramebufferVMObject::fake_sink_framebuffer_physical_pages() const +ReadonlySpan> SharedFramebufferVMObject::fake_sink_framebuffer_physical_pages() const { return m_physical_pages.span(); } @@ -92,7 +92,7 @@ void SharedFramebufferVMObject::switch_to_real_framebuffer_writes(Badge const> SharedFramebufferVMObject::physical_pages() const +ReadonlySpan> SharedFramebufferVMObject::physical_pages() const { SpinlockLocker locker(m_writes_state_lock); if (m_writes_are_faked) diff --git a/Kernel/Memory/SharedFramebufferVMObject.h b/Kernel/Memory/SharedFramebufferVMObject.h index a43144c19a..296189c264 100644 --- a/Kernel/Memory/SharedFramebufferVMObject.h +++ b/Kernel/Memory/SharedFramebufferVMObject.h @@ -29,7 +29,7 @@ public: } virtual StringView class_name() const override { return "FakeWritesFramebufferVMObject"sv; } virtual ErrorOr> try_clone() override { return Error::from_errno(ENOTIMPL); } - virtual Span const> physical_pages() const override { return m_parent_object->fake_sink_framebuffer_physical_pages(); } + virtual ReadonlySpan> physical_pages() const override { return m_parent_object->fake_sink_framebuffer_physical_pages(); } virtual Span> physical_pages() override { return m_parent_object->fake_sink_framebuffer_physical_pages(); } NonnullLockRefPtr m_parent_object; }; @@ -46,7 +46,7 @@ public: } virtual StringView class_name() const override { return "RealWritesFramebufferVMObject"sv; } virtual ErrorOr> try_clone() override { return Error::from_errno(ENOTIMPL); } - virtual Span const> physical_pages() const override { return m_parent_object->real_framebuffer_physical_pages(); } + virtual ReadonlySpan> physical_pages() const override { return m_parent_object->real_framebuffer_physical_pages(); } virtual Span> physical_pages() override { return m_parent_object->real_framebuffer_physical_pages(); } NonnullLockRefPtr m_parent_object; }; @@ -60,14 +60,14 @@ public: void switch_to_fake_sink_framebuffer_writes(Badge); void switch_to_real_framebuffer_writes(Badge); - virtual Span const> physical_pages() const override; + virtual ReadonlySpan> physical_pages() const override; virtual Span> physical_pages() override; Span> fake_sink_framebuffer_physical_pages(); - Span const> fake_sink_framebuffer_physical_pages() const; + ReadonlySpan> fake_sink_framebuffer_physical_pages() const; Span> real_framebuffer_physical_pages(); - Span const> real_framebuffer_physical_pages() const; + ReadonlySpan> real_framebuffer_physical_pages() const; FakeWritesFramebufferVMObject const& fake_writes_framebuffer_vmobject() const { return *m_fake_writes_framebuffer_vmobject; } FakeWritesFramebufferVMObject& fake_writes_framebuffer_vmobject() { return *m_fake_writes_framebuffer_vmobject; } diff --git a/Kernel/Memory/VMObject.h b/Kernel/Memory/VMObject.h index 8dcdf7e098..8f5984d944 100644 --- a/Kernel/Memory/VMObject.h +++ b/Kernel/Memory/VMObject.h @@ -35,7 +35,7 @@ public: size_t page_count() const { return m_physical_pages.size(); } - virtual Span const> physical_pages() const { return m_physical_pages.span(); } + virtual ReadonlySpan> physical_pages() const { return m_physical_pages.span(); } virtual Span> physical_pages() { return m_physical_pages.span(); } size_t size() const { return m_physical_pages.size() * PAGE_SIZE; } diff --git a/Ladybird/HelperProcess.cpp b/Ladybird/HelperProcess.cpp index f5a8ca9873..96128f259a 100644 --- a/Ladybird/HelperProcess.cpp +++ b/Ladybird/HelperProcess.cpp @@ -9,7 +9,7 @@ #include #include -ErrorOr spawn_helper_process(StringView process_name, Span arguments, Core::System::SearchInPath search_in_path, Optional> environment) +ErrorOr spawn_helper_process(StringView process_name, ReadonlySpan arguments, Core::System::SearchInPath search_in_path, Optional> environment) { auto paths = TRY(get_paths_for_helper_process(process_name)); VERIFY(!paths.is_empty()); diff --git a/Ladybird/HelperProcess.h b/Ladybird/HelperProcess.h index c7e54e0778..5003e97c48 100644 --- a/Ladybird/HelperProcess.h +++ b/Ladybird/HelperProcess.h @@ -14,5 +14,5 @@ #include #include -ErrorOr spawn_helper_process(StringView process_name, Span arguments, Core::System::SearchInPath, Optional> environment = {}); +ErrorOr spawn_helper_process(StringView process_name, ReadonlySpan arguments, Core::System::SearchInPath, Optional> environment = {}); ErrorOr> get_paths_for_helper_process(StringView process_name); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp index c9da83a0d4..c54b4fbd45 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp @@ -2215,7 +2215,7 @@ ErrorOr> get_calendar_range12_formats(StringView lo return result; } -static ErrorOr> find_calendar_symbols(StringView locale, StringView calendar, CalendarSymbol symbol, CalendarPatternStyle style) +static ErrorOr> find_calendar_symbols(StringView locale, StringView calendar, CalendarSymbol symbol, CalendarPatternStyle style) { if (auto const* data = TRY(find_calendar_data(locale, calendar)); data != nullptr) { auto const& symbols_list = s_calendar_symbol_lists[data->symbols]; @@ -2243,7 +2243,7 @@ static ErrorOr> find_calendar_symbols(StringView return s_symbol_lists.at(symbol_list_index); } - return Span<@string_index_type@ const> {}; + return ReadonlySpan<@string_index_type@> {}; } ErrorOr> get_calendar_era_symbol(StringView locale, StringView calendar, CalendarPatternStyle style, Era value) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp index ff66825642..cace43b441 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp @@ -1127,7 +1127,7 @@ struct TextLayout { generate_available_values(generator, "get_available_currencies"sv, cldr.currencies); generator.append(R"~~~( -Span get_available_keyword_values(StringView key) +ReadonlySpan get_available_keyword_values(StringView key) { auto key_value = key_from_string(key); if (!key_value.has_value()) @@ -1521,7 +1521,7 @@ Optional get_locale_@enum_snake@_mapping(StringView locale, StringVi generate_value_to_string(generator, "{}_to_string"sv, "CharacterOrder"sv, "character_order"sv, format_identifier, cldr.character_orders); generator.append(R"~~~( -static Span<@string_index_type@ const> find_keyword_indices(StringView locale, StringView key) +static ReadonlySpan<@string_index_type@> find_keyword_indices(StringView locale, StringView key) { auto locale_value = locale_from_string(locale); if (!locale_value.has_value()) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp index 1ecd5b9521..879f85fd92 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp @@ -915,7 +915,7 @@ static Optional keyword_to_number_system(KeywordNumbers keyword) } } -Optional> get_digits_for_number_system(StringView system) +Optional> get_digits_for_number_system(StringView system) { auto number_system_keyword = keyword_nu_from_string(system); if (!number_system_keyword.has_value()) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp index 5f26c62a9e..ebbf19492d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp @@ -622,7 +622,7 @@ PluralCategory determine_plural_category(StringView locale, PluralForm form, Plu return decider(move(operands)); } -Span available_plural_categories(StringView locale, PluralForm form) +ReadonlySpan available_plural_categories(StringView locale, PluralForm form) { auto locale_value = locale_from_string(locale); if (!locale_value.has_value()) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp index f58d04ac85..a1839d01de 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp @@ -151,7 +151,7 @@ struct AK::Formatter : Formatter { } }; -static Optional parse_date_time(Span segments) +static Optional parse_date_time(ReadonlySpan segments) { auto comment_index = find_index(segments.begin(), segments.end(), "#"sv); if (comment_index != segments.size()) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp index 0d4229d048..a3f3e6692b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -228,9 +228,9 @@ struct EmojiData { return emoji; } - constexpr Span code_points() const + constexpr ReadonlySpan code_points() const { - return Span(s_emoji_code_points.data() + code_point_start, code_point_count); + return ReadonlySpan(s_emoji_code_points.data() + code_point_start, code_point_count); } @string_index_type@ name { 0 }; @@ -259,7 +259,7 @@ static constexpr Array s_emojis { {)~~~"); generator.append(R"~~~( } }; -Optional find_emoji_for_code_points(Span code_points) +Optional find_emoji_for_code_points(ReadonlySpan code_points) { for (auto& emoji : s_emojis) { if (emoji.code_points() == code_points) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index 8d7435486e..3fc0c74808 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -856,13 +856,13 @@ struct CodePointDecompositionRaw { struct CodePointDecomposition { u32 code_point { 0 }; CompatibilityFormattingTag tag { CompatibilityFormattingTag::Canonical }; - Span decomposition; + ReadonlySpan decomposition; }; Optional locale_from_string(StringView locale); -Span special_case_mapping(u32 code_point); -Span case_folding_mapping(u32 code_point); +ReadonlySpan special_case_mapping(u32 code_point); +ReadonlySpan case_folding_mapping(u32 code_point); } )~~~"); @@ -1133,7 +1133,7 @@ static constexpr Array @name@ { { generator.set("name", collection_name); generator.set("size", DeprecatedString::number(property_names.size())); generator.append(R"~~~( -static constexpr Array, @size@> @name@ { {)~~~"); +static constexpr Array, @size@> @name@ { {)~~~"); for (auto const& property_name : property_names) { generator.set("name", DeprecatedString::formatted(property_format, property_name)); @@ -1197,7 +1197,7 @@ Optional code_point_block_display_name(u32 code_point) return {}; } -Span block_display_names() +ReadonlySpan block_display_names() { static auto display_names = []() { Array display_names; @@ -1247,7 +1247,7 @@ u32 @method@(u32 code_point) append_code_point_mapping_search("to_unicode_titlecase"sv, "s_titlecase_mappings"sv, "code_point"sv); generator.append(R"~~~( -Span special_case_mapping(u32 code_point) +ReadonlySpan special_case_mapping(u32 code_point) { auto const* mapping = binary_search(s_special_case_mappings, code_point, nullptr, CodePointComparator {}); if (mapping == nullptr) @@ -1256,7 +1256,7 @@ Span special_case_mapping(u32 code_point) return mapping->special_casing.span().slice(0, mapping->special_casing_size); } -Span case_folding_mapping(u32 code_point) +ReadonlySpan case_folding_mapping(u32 code_point) { auto const* mapping = binary_search(s_case_folding_mappings, code_point, nullptr, CodePointComparator {}); if (mapping == nullptr) @@ -1281,7 +1281,7 @@ Optional code_point_decomposition(u32 code_point) auto const* mapping = binary_search(s_decomposition_mappings, code_point, nullptr, CodePointComparator {}); if (mapping == nullptr) return {}; - return CodePointDecomposition { mapping->code_point, mapping->tag, Span { s_decomposition_mappings_data.data() + mapping->decomposition_index, mapping->decomposition_count } }; + return CodePointDecomposition { mapping->code_point, mapping->tag, ReadonlySpan { s_decomposition_mappings_data.data() + mapping->decomposition_index, mapping->decomposition_count } }; } Optional code_point_decomposition_by_index(size_t index) @@ -1289,7 +1289,7 @@ Optional code_point_decomposition_by_index(size_t if (index >= s_decomposition_mappings.size()) return {}; auto const& mapping = s_decomposition_mappings[index]; - return CodePointDecomposition { mapping.code_point, mapping.tag, Span { s_decomposition_mappings_data.data() + mapping.decomposition_index, mapping.decomposition_count } }; + return CodePointDecomposition { mapping.code_point, mapping.tag, ReadonlySpan { s_decomposition_mappings_data.data() + mapping.decomposition_index, mapping.decomposition_count } }; } )~~~"); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index fa25694253..12f8e741f8 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -158,7 +158,7 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~"); generator.append(R"~~~( -static constexpr Array, @size@ + 1> @name@ { { +static constexpr Array, @size@ + 1> @name@ { { {})~~~"); constexpr size_t max_values_per_row = 10; @@ -475,7 +475,7 @@ Optional<@return_type@> @method_name@(StringView key) } template -void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, Span values) +void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, ReadonlySpan values) { generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name)); generator.set("value_type", value_type); @@ -576,7 +576,7 @@ void generate_mapping(SourceGenerator& generator, LocalesType const& locales, St generator.set("name", name); generator.set("size", DeprecatedString::number(locales.size())); generator.append(R"~~~( -static constexpr Array, @size@> @name@ { { +static constexpr Array, @size@> @name@ { { )~~~"); constexpr size_t max_values_per_row = 10; @@ -606,7 +606,7 @@ void generate_available_values(SourceGenerator& generator, StringView name, Vect generator.set("name", name); generator.append(R"~~~( -Span @name@() +ReadonlySpan @name@() { static constexpr auto values = Array {)~~~"); diff --git a/Tests/AK/TestArray.cpp b/Tests/AK/TestArray.cpp index 03038a9958..12aefe5455 100644 --- a/Tests/AK/TestArray.cpp +++ b/Tests/AK/TestArray.cpp @@ -8,7 +8,7 @@ #include -static constexpr int constexpr_sum(Span const span) +static constexpr int constexpr_sum(ReadonlySpan const span) { int sum = 0; for (auto value : span) diff --git a/Tests/AK/TestSpan.cpp b/Tests/AK/TestSpan.cpp index cb0eb626d3..098b34bd47 100644 --- a/Tests/AK/TestSpan.cpp +++ b/Tests/AK/TestSpan.cpp @@ -102,7 +102,7 @@ TEST_CASE(can_subspan_as_intended) { static constexpr u16 buffer[8] { 1, 2, 3, 4, 5, 6, 7, 8 }; - constexpr Span span { buffer, 8 }; + constexpr ReadonlySpan span { buffer, 8 }; constexpr auto slice = span.slice(3, 2); static_assert(slice.size() == 2u); diff --git a/Userland/Applications/Browser/CookieJar.cpp b/Userland/Applications/Browser/CookieJar.cpp index ddb99ccd4a..2e39fce90d 100644 --- a/Userland/Applications/Browser/CookieJar.cpp +++ b/Userland/Applications/Browser/CookieJar.cpp @@ -420,7 +420,7 @@ Vector CookieJar::get_matching_cookies(const URL& url, Depr return cookie_list; } -static ErrorOr parse_cookie(Span row) +static ErrorOr parse_cookie(ReadonlySpan row) { if (row.size() != 12) return Error::from_string_view("Incorrect number of columns to parse cookie"sv); diff --git a/Userland/Applications/Browser/Database.h b/Userland/Applications/Browser/Database.h index bbe05e198c..0ff6a3e216 100644 --- a/Userland/Applications/Browser/Database.h +++ b/Userland/Applications/Browser/Database.h @@ -21,7 +21,7 @@ namespace Browser { class Database : public RefCounted { - using OnResult = Function)>; + using OnResult = Function)>; using OnComplete = Function; using OnError = Function; diff --git a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp index fee8be799f..a4bee4981d 100644 --- a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp @@ -24,7 +24,7 @@ #include #include -using StringViewListModel = GUI::ItemListModel>; +using StringViewListModel = GUI::ItemListModel>; static constexpr auto PI_OVER_180 = M_PIf32 / 180.0f; static constexpr auto PI_OVER_4 = M_PIf32 / 4.0f; diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index d152fc69f4..64a43c3e3e 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -366,7 +366,7 @@ void HexEditorWidget::update_inspector_values(size_t position) value_inspector_model->set_parsed_value(ValueInspectorModel::ValueType::UTF8, utf8_view.unicode_substring_view(0, 1).as_string()); if (byte_read_count % 2 == 0) { - Utf16View utf16_view { Span { reinterpret_cast(&unsigned_64_bit_int), 4 } }; + Utf16View utf16_view { ReadonlySpan { reinterpret_cast(&unsigned_64_bit_int), 4 } }; size_t valid_code_units; utf16_view.validate(valid_code_units); if (valid_code_units == 0) diff --git a/Userland/Games/2048/Game.cpp b/Userland/Games/2048/Game.cpp index 8076e1d852..5552d63be3 100644 --- a/Userland/Games/2048/Game.cpp +++ b/Userland/Games/2048/Game.cpp @@ -141,7 +141,7 @@ static bool is_complete(Game::Board const& board, size_t target) return false; } -static bool has_no_neighbors(Span const& row) +static bool has_no_neighbors(ReadonlySpan const& row) { if (row.size() < 2) return true; diff --git a/Userland/Libraries/LibAudio/MP3HuffmanTables.h b/Userland/Libraries/LibAudio/MP3HuffmanTables.h index 3c54000506..ee4bee58d5 100644 --- a/Userland/Libraries/LibAudio/MP3HuffmanTables.h +++ b/Userland/Libraries/LibAudio/MP3HuffmanTables.h @@ -106,7 +106,7 @@ struct HuffmanDecodeResult { }; template -HuffmanDecodeResult huffman_decode(BigEndianInputBitStream& bitstream, Span const> tree, size_t max_bits_to_read) +HuffmanDecodeResult huffman_decode(BigEndianInputBitStream& bitstream, ReadonlySpan> tree, size_t max_bits_to_read) { HuffmanNode const* node = &tree[0]; size_t bits_read = 0; @@ -1681,7 +1681,7 @@ constexpr auto Tree30 = make_huffman_tree(); constexpr auto Tree31 = make_huffman_tree(); struct HuffmanTreeXY { - Span const> nodes; + ReadonlySpan> nodes; int linbits; }; diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp index 59a90cf233..c36287112f 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.cpp +++ b/Userland/Libraries/LibAudio/MP3Loader.cpp @@ -555,7 +555,7 @@ MaybeLoaderError MP3LoaderPlugin::read_huffman_data(MP3::MP3Frame& frame, BigEnd granule.samples[count + 1] = requantize(y, exponents[count + 1]); } - Span const> count1table = granule.count1table_select ? MP3::Tables::Huffman::TreeB : MP3::Tables::Huffman::TreeA; + ReadonlySpan> count1table = granule.count1table_select ? MP3::Tables::Huffman::TreeB : MP3::Tables::Huffman::TreeA; // count1 is not known. We have to read huffman encoded values // until we've exhausted the granule's bits. We know the size of @@ -672,7 +672,7 @@ void MP3LoaderPlugin::process_stereo(MP3::MP3Frame& frame, size_t granule_index) auto& granule_left = frame.channels[0].granules[granule_index]; auto& granule_right = frame.channels[1].granules[granule_index]; - auto get_last_nonempty_band = [](Span samples, Span bands) -> size_t { + auto get_last_nonempty_band = [](Span samples, ReadonlySpan bands) -> size_t { size_t last_nonempty_band = 0; for (size_t i = 0; i < bands.size(); i++) { @@ -781,7 +781,7 @@ void MP3LoaderPlugin::transform_samples_to_time(Array const& input, output[i] = 0; } else { - s_mdct_36.transform(Span(input).slice(input_offset, 18), output); + s_mdct_36.transform(ReadonlySpan(input).slice(input_offset, 18), output); for (size_t i = 0; i < 36; i++) { switch (block_type) { case MP3::BlockType::Normal: @@ -837,7 +837,7 @@ void MP3LoaderPlugin::synthesis(Array& V, Array& samples } } -Span MP3LoaderPlugin::get_scalefactor_bands(MP3::Granule const& granule, int samplerate) +ReadonlySpan MP3LoaderPlugin::get_scalefactor_bands(MP3::Granule const& granule, int samplerate) { switch (granule.block_type) { case MP3::BlockType::Short: diff --git a/Userland/Libraries/LibAudio/MP3Loader.h b/Userland/Libraries/LibAudio/MP3Loader.h index 3568745f6e..f64bf30b00 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.h +++ b/Userland/Libraries/LibAudio/MP3Loader.h @@ -56,7 +56,7 @@ private: static void process_stereo(MP3::MP3Frame&, size_t granule_index); static void transform_samples_to_time(Array const& input, size_t input_offset, Array& output, MP3::BlockType block_type); static void synthesis(Array& V, Array& samples, Array& result); - static Span get_scalefactor_bands(MP3::Granule const&, int samplerate); + static ReadonlySpan get_scalefactor_bands(MP3::Granule const&, int samplerate); AK::Vector> m_seek_table; AK::Array, 32>, 2> m_last_values {}; diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 76456c0d34..a3448921dd 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -132,7 +132,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha } if (m_perform_autocomplete) { - autocomplete(stdout, { argv[0], strlen(argv[0]) }, Span { argv + optind, static_cast(argc - optind) }); + autocomplete(stdout, { argv[0], strlen(argv[0]) }, ReadonlySpan { argv + optind, static_cast(argc - optind) }); if (failure_behavior == FailureBehavior::Exit || failure_behavior == FailureBehavior::PrintUsageAndExit) exit(0); return false; @@ -731,7 +731,7 @@ void ArgsParser::add_positional_argument(Vector& values, char const* add_positional_argument(move(arg)); } -void ArgsParser::autocomplete(FILE* file, StringView program_name, Span remaining_arguments) +void ArgsParser::autocomplete(FILE* file, StringView program_name, ReadonlySpan remaining_arguments) { // We expect the full invocation of the program to be available as positional args, // e.g. `foo --bar arg -b` (program invoked as `foo --complete -- foo --bar arg -b`) diff --git a/Userland/Libraries/LibCore/ArgsParser.h b/Userland/Libraries/LibCore/ArgsParser.h index 66331760de..389b79c946 100644 --- a/Userland/Libraries/LibCore/ArgsParser.h +++ b/Userland/Libraries/LibCore/ArgsParser.h @@ -112,7 +112,7 @@ public: void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); private: - void autocomplete(FILE*, StringView program_name, Span remaining_arguments); + void autocomplete(FILE*, StringView program_name, ReadonlySpan remaining_arguments); Vector