瀏覽代碼

LibIPC: Remove redundant IPC::Dictionary type

We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is essentially equivalent.
Ben Wiederhake 2 年之前
父節點
當前提交
943ecaede6

+ 0 - 1
Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp

@@ -779,7 +779,6 @@ void build(StringBuilder& builder, Vector<Endpoint> const& endpoints)
 #include <AK/Utf8View.h>
 #include <LibIPC/Connection.h>
 #include <LibIPC/Decoder.h>
-#include <LibIPC/Dictionary.h>
 #include <LibIPC/Encoder.h>
 #include <LibIPC/File.h>
 #include <LibIPC/Message.h>

+ 0 - 16
Userland/Libraries/LibIPC/Decoder.cpp

@@ -13,7 +13,6 @@
 #include <LibCore/Proxy.h>
 #include <LibCore/Socket.h>
 #include <LibIPC/Decoder.h>
-#include <LibIPC/Dictionary.h>
 #include <LibIPC/File.h>
 #include <fcntl.h>
 
@@ -84,21 +83,6 @@ ErrorOr<URL> decode(Decoder& decoder)
     return URL { url };
 }
 
-template<>
-ErrorOr<Dictionary> decode(Decoder& decoder)
-{
-    auto size = TRY(decoder.decode_size());
-    Dictionary dictionary {};
-
-    for (size_t i = 0; i < size; ++i) {
-        auto key = TRY(decoder.decode<DeprecatedString>());
-        auto value = TRY(decoder.decode<DeprecatedString>());
-        dictionary.add(move(key), move(value));
-    }
-
-    return dictionary;
-}
-
 template<>
 ErrorOr<File> decode(Decoder& decoder)
 {

+ 0 - 3
Userland/Libraries/LibIPC/Decoder.h

@@ -99,9 +99,6 @@ ErrorOr<Time> decode(Decoder&);
 template<>
 ErrorOr<URL> decode(Decoder&);
 
-template<>
-ErrorOr<Dictionary> decode(Decoder&);
-
 template<>
 ErrorOr<File> decode(Decoder&);
 

+ 0 - 55
Userland/Libraries/LibIPC/Dictionary.h

@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2022, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Concepts.h>
-#include <AK/DeprecatedString.h>
-#include <AK/HashMap.h>
-
-namespace IPC {
-
-class Dictionary {
-public:
-    Dictionary() = default;
-
-    Dictionary(HashMap<DeprecatedString, DeprecatedString>&& initial_entries)
-        : m_entries(move(initial_entries))
-    {
-    }
-
-    bool is_empty() const { return m_entries.is_empty(); }
-    size_t size() const { return m_entries.size(); }
-
-    void add(DeprecatedString key, DeprecatedString value)
-    {
-        m_entries.set(move(key), move(value));
-    }
-
-    template<typename Callback>
-    void for_each_entry(Callback callback) const
-    {
-        for (auto& it : m_entries) {
-            callback(it.key, it.value);
-        }
-    }
-
-    template<FallibleFunction<DeprecatedString const&, DeprecatedString const&> Callback>
-    ErrorOr<void> try_for_each_entry(Callback&& callback) const
-    {
-        for (auto const& it : m_entries)
-            TRY(callback(it.key, it.value));
-        return {};
-    }
-
-    HashMap<DeprecatedString, DeprecatedString> const& entries() const { return m_entries; }
-
-private:
-    HashMap<DeprecatedString, DeprecatedString> m_entries;
-};
-
-}

+ 0 - 15
Userland/Libraries/LibIPC/Encoder.cpp

@@ -19,7 +19,6 @@
 #include <LibCore/DateTime.h>
 #include <LibCore/Proxy.h>
 #include <LibCore/System.h>
-#include <LibIPC/Dictionary.h>
 #include <LibIPC/Encoder.h>
 #include <LibIPC/File.h>
 
@@ -97,20 +96,6 @@ ErrorOr<void> encode(Encoder& encoder, URL const& value)
     return encoder.encode(value.to_deprecated_string());
 }
 
-template<>
-ErrorOr<void> encode(Encoder& encoder, Dictionary const& dictionary)
-{
-    TRY(encoder.encode_size(dictionary.size()));
-
-    TRY(dictionary.try_for_each_entry([&](auto const& key, auto const& value) -> ErrorOr<void> {
-        TRY(encoder.encode(key));
-        TRY(encoder.encode(value));
-        return {};
-    }));
-
-    return {};
-}
-
 template<>
 ErrorOr<void> encode(Encoder& encoder, File const& file)
 {

+ 0 - 3
Userland/Libraries/LibIPC/Encoder.h

@@ -128,9 +128,6 @@ ErrorOr<void> encode(Encoder&, Time const&);
 template<>
 ErrorOr<void> encode(Encoder&, URL const&);
 
-template<>
-ErrorOr<void> encode(Encoder&, Dictionary const&);
-
 template<>
 ErrorOr<void> encode(Encoder&, File const&);
 

+ 0 - 1
Userland/Libraries/LibIPC/Forward.h

@@ -11,7 +11,6 @@
 namespace IPC {
 
 class Decoder;
-class Dictionary;
 class Encoder;
 class Message;
 class File;