Clipboard: Avoid unnecessary IPC::Dictionary wrapper

We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is equivalent.
This commit is contained in:
Ben Wiederhake 2023-05-14 23:04:47 +02:00 committed by Andreas Kling
parent 67d9172885
commit 0ee5a4e308
Notes: sideshowbarker 2024-07-17 01:46:43 +09:00
5 changed files with 13 additions and 8 deletions

View file

@ -59,9 +59,14 @@ Clipboard::DataAndType Clipboard::fetch_data_and_type() const
{
auto response = connection().get_clipboard_data();
auto type = response.mime_type();
auto metadata = response.metadata().entries();
auto metadata = response.metadata();
auto metadata_clone_or_error = metadata.clone();
if (metadata_clone_or_error.is_error())
return {};
if (!response.data().is_valid())
return { {}, type, metadata };
return { {}, type, metadata_clone_or_error.release_value() };
auto data = ByteBuffer::copy(response.data().data<void>(), response.data().size());
if (data.is_error())
return {};

View file

@ -2,6 +2,6 @@
endpoint ClipboardServer
{
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, IPC::Dictionary metadata)
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, IPC::Dictionary metadata) =|
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata)
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata) =|
}

View file

@ -30,9 +30,9 @@ void ConnectionFromClient::die()
s_connections.remove(client_id());
}
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, DeprecatedString const& mime_type, IPC::Dictionary const& metadata)
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, DeprecatedString const& mime_type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
{
Storage::the().set_data(data, mime_type, metadata.entries());
Storage::the().set_data(data, mime_type, metadata);
}
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()

View file

@ -30,7 +30,7 @@ private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, IPC::Dictionary const&) override;
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, HashMap<DeprecatedString, DeprecatedString> const&) override;
};
}

View file

@ -17,7 +17,7 @@ RefPtr<Gfx::Bitmap> ConnectionToClipboardServer::get_bitmap()
if (clipping.mime_type() != "image/x-serenityos")
return nullptr;
HashMap<DeprecatedString, DeprecatedString> const& metadata = clipping.metadata().entries();
HashMap<DeprecatedString, DeprecatedString> const& metadata = clipping.metadata();
auto width = metadata.get("width").value_or("0").to_uint();
if (!width.has_value() || width.value() == 0)
return nullptr;