diff options
author | Linus Groh <mail@linusgroh.de> | 2022-07-17 00:34:25 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-17 00:34:25 +0100 |
commit | ac36d272d32812899204b0b91ee9c50411e459f2 (patch) | |
tree | e2c817a822222befa30a6090474bbfa00dc2321d /Userland | |
parent | 5806eeec08675487eb6ce1e06b257bfec381fb21 (diff) | |
download | serenity-ac36d272d32812899204b0b91ee9c50411e459f2.zip |
LibWeb: Avoid needless copies during Blob construction
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/FileAPI/Blob.h | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index cf29064b41..1fc9d67b7d 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -12,7 +12,7 @@ namespace Web::FileAPI { -Blob::Blob(ByteBuffer const& byte_buffer, String const& type) +Blob::Blob(ByteBuffer byte_buffer, String type) : m_byte_buffer(move(byte_buffer)) , m_type(move(type)) { @@ -41,7 +41,7 @@ DOM::ExceptionOr<NonnullRefPtr<Blob>> Blob::create(Optional<Vector<BlobPart>> co } // 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above. - return adopt_ref(*new Blob(byte_buffer, type)); + return adopt_ref(*new Blob(move(byte_buffer), move(type))); } DOM::ExceptionOr<NonnullRefPtr<Blob>> Blob::create_with_global_object(Bindings::WindowObject&, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options) @@ -149,7 +149,7 @@ DOM::ExceptionOr<NonnullRefPtr<Blob>> Blob::slice(Optional<i64> start, Optional< auto byte_buffer_or_error = m_byte_buffer.slice(relative_start, span); if (byte_buffer_or_error.is_error()) return DOM::UnknownError::create("Out of memory."sv); - return adopt_ref(*new Blob(byte_buffer_or_error.release_value(), relative_content_type)); + return adopt_ref(*new Blob(byte_buffer_or_error.release_value(), move(relative_content_type))); } // https://w3c.github.io/FileAPI/#dom-blob-text diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index 8930642ebc..e47176b08f 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -33,8 +33,7 @@ class Blob public: using WrapperType = Bindings::BlobWrapper; - - Blob(ByteBuffer const& byte_buffer, String const& type); + Blob(ByteBuffer byte_buffer, String type); static DOM::ExceptionOr<NonnullRefPtr<Blob>> create(Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {}); static DOM::ExceptionOr<NonnullRefPtr<Blob>> create_with_global_object(Bindings::WindowObject&, Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {}); |