From a104e44e3e56283eb73d6c2aba030300374b01aa Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 23 Feb 2023 12:53:33 -0800 Subject: [PATCH] ircd::http: Simplify interface w/ util::closure_bool. --- include/ircd/http.h | 10 ++++------ ircd/http.cc | 19 ++----------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/include/ircd/http.h b/include/ircd/http.h index 3f4a676ab..65af51abc 100644 --- a/include/ircd/http.h +++ b/include/ircd/http.h @@ -223,7 +223,7 @@ struct ircd::http::query struct ircd::http::query::string :string_view { - using closure = std::function; + using closure = util::function_bool; bool for_each(const closure &) const; bool for_each(const string_view &key, const closure &) const; @@ -271,19 +271,17 @@ struct ircd::http::header struct ircd::http::headers :string_view { - using closure = std::function; - using closure_bool = std::function; + using closure = util::function_bool; static const string_view terminator; // "\r\n\r\n" - bool for_each(const closure_bool &) const; + bool for_each(const closure &) const; string_view operator[](const string_view &key) const; string_view at(const string_view &key) const; bool has(const string_view &key) const; using string_view::string_view; - headers(parse::capstan &, closure_bool); - headers(parse::capstan &, const closure & = {}); + headers(parse::capstan &, closure = {}); headers() = default; friend bool has(const headers &, const string_view &key); diff --git a/ircd/http.cc b/ircd/http.cc index 7c39d6fc5..b12d9ee6c 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -652,22 +652,7 @@ ircd::http::headers::terminator }; ircd::http::headers::headers(parse::capstan &pc, - const closure &c) -:headers -{ - pc, closure_bool{[&c](const auto &header) - { - if(c) - c(header); - - return true; - }} -} -{ -} - -ircd::http::headers::headers(parse::capstan &pc, - closure_bool c) + closure c) :string_view{[&pc, &c] () -> string_view { @@ -729,7 +714,7 @@ const } bool -ircd::http::headers::for_each(const closure_bool &closure) +ircd::http::headers::for_each(const closure &closure) const { if(empty())