Skip to content

Commit 5ed4438

Browse files
committed
header cleanup
1 parent da91b17 commit 5ed4438

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/aur/client.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "aur/client.hh"
33

44
#include <curl/curl.h>
5-
#include <fcntl.h>
65
#include <systemd/sd-event.h>
76
#include <unistd.h>
87

@@ -189,16 +188,12 @@ class TypedResponseHandler : public ResponseHandler {
189188
: ResponseHandler(client), callback_(std::move(callback)) {}
190189

191190
protected:
192-
absl::StatusOr<ResponseT> MakeResponse() {
193-
return ResponseT::Parse(std::move(body));
194-
}
195-
196191
int RunCallback(absl::Status status) override {
197-
if (status.ok()) {
198-
return std::move(callback_)(MakeResponse());
199-
} else {
192+
if (!status.ok()) {
200193
return std::move(callback_)(std::move(status));
201194
}
195+
196+
return std::move(callback_)(ResponseT::Parse(std::move(body)));
202197
}
203198

204199
private:

src/aur/response.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: MIT
22
#include "aur/response.hh"
33

4-
#include "absl/base/no_destructor.h"
54
#include "aur/json_internal.hh"
65

76
using nlohmann::json;
@@ -10,9 +9,9 @@ namespace aur {
109

1110
absl::StatusOr<RpcResponse> RpcResponse::Parse(std::string_view bytes) {
1211
try {
13-
json j = json::parse(bytes);
14-
if (auto iter = j.find("error"); iter != j.end()) {
15-
return absl::InvalidArgumentError(iter->get<std::string>());
12+
const json j = json::parse(bytes);
13+
if (const auto iter = j.find("error"); iter != j.end()) {
14+
return absl::InvalidArgumentError(iter->get<std::string_view>());
1615
}
1716

1817
return RpcResponse(j["results"].get<std::vector<Package>>());

src/aur/response.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#ifndef AUR_RESPONSE_HH_
33
#define AUR_RESPONSE_HH_
44

5-
#include "absl/status/status.h"
5+
#include <string>
6+
#include <string_view>
7+
#include <vector>
8+
69
#include "absl/status/statusor.h"
710
#include "aur/package.hh"
811

0 commit comments

Comments
 (0)