From 0f78b06e8c578819f831a513490278a5f70b01af Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Thu, 7 Nov 2019 05:45:06 +0000 Subject: Various improvements to the ZMQ JSON-RPC handling: - Finding handling function in ZMQ JSON-RPC now uses binary search - Temporary `std::vector`s in JSON output now use `epee::span` to prevent allocations. - Binary -> hex in JSON output no longer allocates temporary buffer - C++ structs -> JSON skips intermediate DOM creation, and instead write directly to an output stream. --- contrib/epee/include/hex.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'contrib/epee') diff --git a/contrib/epee/include/hex.h b/contrib/epee/include/hex.h index 6e720f128..4e8f90786 100644 --- a/contrib/epee/include/hex.h +++ b/contrib/epee/include/hex.h @@ -51,12 +51,22 @@ namespace epee template static std::array array(const std::array& src) noexcept { - std::array out{{}}; + std::array out; static_assert(N <= 128, "keep the stack size down"); buffer_unchecked(out.data(), {src.data(), src.size()}); return out; } + //! \return An array containing hex of `src`. + template + static std::array array(const T& src) noexcept + { + std::array out; + static_assert(sizeof(T) <= 128, "keep the stack size down"); + buffer_unchecked(out.data(), as_byte_span(src)); + return out; + } + //! Append `src` as hex to `out`. static void buffer(std::ostream& out, const span src); -- cgit v1.2.3