diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-12-05 01:46:15 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-05 17:49:47 +0100 |
commit | 3cf93d0dd2377b3ce85362db05e47a373006a56e (patch) | |
tree | f902b1ad7d2d5e68958aadf5b92da07fb228a55d | |
parent | 385ba1280b7eb47eba116f9d519c1d8524f25999 (diff) | |
download | serenity-3cf93d0dd2377b3ce85362db05e47a373006a56e.zip |
LibAudio: Stop passing `Bytes` by reference
`Bytes` is very slim, so the memory and/or performance gains from
passing it by reference isn't that big, and it passing it by value is
more compatible with xvalues, which is handy for things like
`::try_create(buffer.bytes())`.
-rw-r--r-- | Userland/Libraries/LibAudio/Loader.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/Loader.h | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibAudio/Loader.cpp b/Userland/Libraries/LibAudio/Loader.cpp index c44bbddcb9..2554378c2b 100644 --- a/Userland/Libraries/LibAudio/Loader.cpp +++ b/Userland/Libraries/LibAudio/Loader.cpp @@ -56,7 +56,7 @@ Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(StringView p return LoaderError { "No loader plugin available" }; } -Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(Bytes& buffer) +Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(Bytes buffer) { NonnullOwnPtr<LoaderPlugin> plugin = adopt_own(*new WavLoaderPlugin(buffer)); if (auto initstate = plugin->initialize(); !initstate.is_error()) diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h index 3469e982c3..2afc078573 100644 --- a/Userland/Libraries/LibAudio/Loader.h +++ b/Userland/Libraries/LibAudio/Loader.h @@ -72,7 +72,7 @@ protected: class Loader : public RefCounted<Loader> { public: static Result<NonnullRefPtr<Loader>, LoaderError> create(StringView path) { return adopt_ref(*new Loader(TRY(try_create(path)))); } - static Result<NonnullRefPtr<Loader>, LoaderError> create(Bytes& buffer) { return adopt_ref(*new Loader(TRY(try_create(buffer)))); } + static Result<NonnullRefPtr<Loader>, LoaderError> create(Bytes buffer) { return adopt_ref(*new Loader(TRY(try_create(buffer)))); } LoaderSamples get_more_samples(size_t max_samples_to_read_from_input = 128 * KiB) const { return m_plugin->get_more_samples(max_samples_to_read_from_input); } @@ -89,7 +89,7 @@ public: private: static Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> try_create(StringView path); - static Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> try_create(Bytes& buffer); + static Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> try_create(Bytes buffer); explicit Loader(NonnullOwnPtr<LoaderPlugin>); |