Skip to content

Commit d20e61a

Browse files
committed
chore: keep bbapi dispatch inline
1 parent 5267841 commit d20e61a

2 files changed

Lines changed: 17 additions & 22 deletions

File tree

barretenberg/cpp/src/barretenberg/bbapi/bbapi_execute.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
#include "bbapi_execute.hpp"
2-
#include <type_traits>
3-
#include <utility>
42

53
namespace bb::bbapi {
6-
7-
CommandResponse execute(BBApiRequest& request, Command&& command)
8-
{
9-
// Reset error state before execution
10-
request.error_message.clear();
11-
12-
CommandResponse response = std::move(command).visit([&request](auto&& cmd) -> CommandResponse {
13-
using CmdType = std::decay_t<decltype(cmd)>;
14-
return std::forward<CmdType>(cmd).execute(request);
15-
});
16-
17-
// Check if an error occurred during execution
18-
if (!request.error_message.empty()) {
19-
return ErrorResponse{ .message = std::move(request.error_message) };
20-
}
21-
22-
return response;
23-
}
24-
254
namespace { // anonymous
265
struct Api {
276
Command commands;

barretenberg/cpp/src/barretenberg/bbapi/bbapi_execute.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ using CommandResponse = NamedUnion<ErrorResponse,
149149
* @param request The circuit registry (acting as the request context).
150150
* @return A variant of all possible command responses.
151151
*/
152-
CommandResponse execute(BBApiRequest& request, Command&& command);
152+
inline CommandResponse execute(BBApiRequest& request, Command&& command)
153+
{
154+
// Reset error state before execution
155+
request.error_message.clear();
156+
157+
CommandResponse response = std::move(command).visit([&request](auto&& cmd) -> CommandResponse {
158+
using CmdType = std::decay_t<decltype(cmd)>;
159+
return std::forward<CmdType>(cmd).execute(request);
160+
});
161+
162+
// Check if an error occurred during execution
163+
if (!request.error_message.empty()) {
164+
return ErrorResponse{ .message = std::move(request.error_message) };
165+
}
166+
167+
return response;
168+
}
153169

154170
} // namespace bb::bbapi

0 commit comments

Comments
 (0)