From 79aa49d04f7797cd26473ce2b71cfedc25c47dd6 Mon Sep 17 00:00:00 2001 From: Lenny Maiorani Date: Thu, 3 Mar 2022 11:35:10 -0700 Subject: [PATCH] Libraries: Use default constructors/destructors in LibHTTP https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler." --- Userland/Libraries/LibHTTP/HttpRequest.cpp | 9 +-------- Userland/Libraries/LibHTTP/HttpRequest.h | 5 +++-- Userland/Libraries/LibHTTP/HttpResponse.cpp | 5 +---- Userland/Libraries/LibHTTP/HttpResponse.h | 3 ++- Userland/Libraries/LibHTTP/Job.cpp | 5 +---- Userland/Libraries/LibHTTP/Job.h | 4 ++-- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp index bea1a98b18..5d098e8447 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.cpp +++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,14 +12,6 @@ namespace HTTP { -HttpRequest::HttpRequest() -{ -} - -HttpRequest::~HttpRequest() -{ -} - String HttpRequest::method_name() const { switch (m_method) { diff --git a/Userland/Libraries/LibHTTP/HttpRequest.h b/Userland/Libraries/LibHTTP/HttpRequest.h index e233c6e0ab..5cb71b6e5b 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.h +++ b/Userland/Libraries/LibHTTP/HttpRequest.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -34,8 +35,8 @@ public: String password; }; - HttpRequest(); - ~HttpRequest(); + HttpRequest() = default; + ~HttpRequest() = default; String const& resource() const { return m_resource; } Vector
const& headers() const { return m_headers; } diff --git a/Userland/Libraries/LibHTTP/HttpResponse.cpp b/Userland/Libraries/LibHTTP/HttpResponse.cpp index fbea69cc39..f77138a1c4 100644 --- a/Userland/Libraries/LibHTTP/HttpResponse.cpp +++ b/Userland/Libraries/LibHTTP/HttpResponse.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,10 +16,6 @@ HttpResponse::HttpResponse(int code, HashMap= 100 && code <= 599); diff --git a/Userland/Libraries/LibHTTP/HttpResponse.h b/Userland/Libraries/LibHTTP/HttpResponse.h index c4ba77ec5a..27b9f26995 100644 --- a/Userland/Libraries/LibHTTP/HttpResponse.h +++ b/Userland/Libraries/LibHTTP/HttpResponse.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -14,7 +15,7 @@ namespace HTTP { class HttpResponse : public Core::NetworkResponse { public: - virtual ~HttpResponse() override; + virtual ~HttpResponse() override = default; static NonnullRefPtr create(int code, HashMap&& headers, size_t downloaded_size) { return adopt_ref(*new HttpResponse(code, move(headers), downloaded_size)); diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index bc0104ea34..1c0a901cf1 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -77,10 +78,6 @@ Job::Job(HttpRequest&& request, Core::Stream::Stream& output_stream) { } -Job::~Job() -{ -} - void Job::start(Core::Stream::Socket& socket) { VERIFY(!m_socket); diff --git a/Userland/Libraries/LibHTTP/Job.h b/Userland/Libraries/LibHTTP/Job.h index 91eeac4fce..eef352410d 100644 --- a/Userland/Libraries/LibHTTP/Job.h +++ b/Userland/Libraries/LibHTTP/Job.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2020-2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -21,7 +21,7 @@ class Job : public Core::NetworkJob { public: explicit Job(HttpRequest&&, Core::Stream::Stream&); - virtual ~Job() override; + virtual ~Job() override = default; virtual void start(Core::Stream::Socket&) override; virtual void shutdown(ShutdownMode) override;