mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
perf: use small::vector<> when sorting map keys (#7928)
I collected stats for a full day & found N=32 to be enough for 99% of cases
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <fmt/compile.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <small/vector.hpp>
|
||||
|
||||
#define LIBTRANSMISSION_VARIANT_MODULE
|
||||
|
||||
#include "libtransmission/benc.h"
|
||||
@@ -279,7 +281,8 @@ using OutBuf = fmt::memory_buffer;
|
||||
|
||||
[[nodiscard]] auto sorted_entries(tr_variant::Map const& map)
|
||||
{
|
||||
auto entries = std::vector<std::pair<std::string_view, tr_variant const*>>{};
|
||||
static auto constexpr N = 32U;
|
||||
auto entries = small::vector<std::pair<std::string_view, tr_variant const*>, N>{};
|
||||
entries.reserve(map.size());
|
||||
for (auto const& [key, child] : map)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <small/vector.hpp>
|
||||
|
||||
#include <rapidjson/encodedstream.h>
|
||||
#include <rapidjson/encodings.h>
|
||||
#include <rapidjson/error/en.h>
|
||||
@@ -294,7 +296,8 @@ private:
|
||||
|
||||
[[nodiscard]] auto sorted_entries(tr_variant::Map const& map)
|
||||
{
|
||||
auto entries = std::vector<std::pair<std::string_view, tr_variant const*>>{};
|
||||
static auto constexpr N = 32U;
|
||||
auto entries = small::vector<std::pair<std::string_view, tr_variant const*>, N>{};
|
||||
entries.reserve(map.size());
|
||||
for (auto const& [key, child] : map)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user