diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-02-05 20:18:07 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-06 13:10:10 +0100 |
commit | 07f444439ce0071f0f005d72065c2b76f8d68841 (patch) | |
tree | 54c71005698f5dbb4203ad7b04f441d935af4ab3 /Userland | |
parent | 8a1dfbd484d729facdd8d39e7360c7b2985a6617 (diff) | |
download | serenity-07f444439ce0071f0f005d72065c2b76f8d68841.zip |
LibCore: Take StringViews by value in Stream::* function arguments
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCore/Stream.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/Stream.h | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index 5a8ba56e05..21988042b3 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -91,7 +91,7 @@ ErrorOr<off_t> SeekableStream::size() return seek_result.value(); } -ErrorOr<NonnullOwnPtr<File>> File::open(StringView const& filename, OpenMode mode, mode_t permissions) +ErrorOr<NonnullOwnPtr<File>> File::open(StringView filename, OpenMode mode, mode_t permissions) { auto file = TRY(adopt_nonnull_own_or_enomem(new (nothrow) File(mode))); TRY(file->open_path(filename, permissions)); @@ -114,7 +114,7 @@ ErrorOr<NonnullOwnPtr<File>> File::adopt_fd(int fd, OpenMode mode) return file; } -ErrorOr<void> File::open_path(StringView const& filename, mode_t permissions) +ErrorOr<void> File::open_path(StringView filename, mode_t permissions) { VERIFY(m_fd == -1); diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h index f5ae204fde..0e04e5153f 100644 --- a/Userland/Libraries/LibCore/Stream.h +++ b/Userland/Libraries/LibCore/Stream.h @@ -166,7 +166,7 @@ class File final : public SeekableStream { AK_MAKE_NONCOPYABLE(File); public: - static ErrorOr<NonnullOwnPtr<File>> open(StringView const& filename, OpenMode, mode_t = 0644); + static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644); static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode); File(File&& other) { operator=(move(other)); } @@ -199,7 +199,7 @@ private: { } - ErrorOr<void> open_path(StringView const& filename, mode_t); + ErrorOr<void> open_path(StringView filename, mode_t); OpenMode m_mode { OpenMode::NotOpen }; int m_fd { -1 }; @@ -542,7 +542,7 @@ public: return read_until(buffer, "\n"sv); } - ErrorOr<size_t> read_until(Bytes buffer, StringView const& candidate) + ErrorOr<size_t> read_until(Bytes buffer, StringView candidate) { return read_until_any_of(buffer, Array { candidate }); } @@ -724,7 +724,7 @@ public: } ErrorOr<size_t> read_line(Bytes buffer) { return m_helper.read_line(move(buffer)); } - ErrorOr<size_t> read_until(Bytes buffer, StringView const& candidate) { return m_helper.read_until(move(buffer), move(candidate)); } + ErrorOr<size_t> read_until(Bytes buffer, StringView candidate) { return m_helper.read_until(move(buffer), move(candidate)); } template<size_t N> ErrorOr<size_t> read_until_any_of(Bytes buffer, Array<StringView, N> candidates) { return m_helper.read_until_any_of(move(buffer), move(candidates)); } ErrorOr<bool> can_read_line() { return m_helper.can_read_line(); } @@ -745,7 +745,7 @@ private: class BufferedSocketBase : public Socket { public: virtual ErrorOr<size_t> read_line(Bytes buffer) = 0; - virtual ErrorOr<size_t> read_until(Bytes buffer, StringView const& candidate) = 0; + virtual ErrorOr<size_t> read_until(Bytes buffer, StringView candidate) = 0; virtual ErrorOr<bool> can_read_line() = 0; virtual size_t buffer_size() const = 0; }; @@ -789,7 +789,7 @@ public: virtual ErrorOr<void> set_close_on_exec(bool enabled) override { return m_helper.stream().set_close_on_exec(enabled); } virtual ErrorOr<size_t> read_line(Bytes buffer) override { return m_helper.read_line(move(buffer)); } - virtual ErrorOr<size_t> read_until(Bytes buffer, StringView const& candidate) override { return m_helper.read_until(move(buffer), move(candidate)); } + virtual ErrorOr<size_t> read_until(Bytes buffer, StringView candidate) override { return m_helper.read_until(move(buffer), move(candidate)); } template<size_t N> ErrorOr<size_t> read_until_any_of(Bytes buffer, Array<StringView, N> candidates) { return m_helper.read_until_any_of(move(buffer), move(candidates)); } virtual ErrorOr<bool> can_read_line() override { return m_helper.can_read_line(); } |