diff --git a/perf/benchmark-set.cc b/perf/benchmark-set.cc index 547d69cdf..1c5ceacfe 100644 --- a/perf/benchmark-set.cc +++ b/perf/benchmark-set.cc @@ -120,4 +120,27 @@ BENCHMARK(BM_SetIteration) {{1 << 10, 1 << 16}, // Set Size {2, 512}}); // Density +/* Set copy. */ +static void BM_SetCopy(benchmark::State& state) { + unsigned set_size = state.range(0); + unsigned max_value = state.range(0) * state.range(1); + + hb_set_t* original = hb_set_create (); + RandomSet(set_size, max_value, original); + assert(hb_set_get_population(original) == set_size); + + for (auto _ : state) { + hb_set_t *s = hb_set_create (); + hb_set_set (s, original); + hb_set_destroy (s); + } + + hb_set_destroy(original); +} +BENCHMARK(BM_SetCopy) + ->Unit(benchmark::kMicrosecond) + ->Ranges( + {{1 << 10, 1 << 16}, // Set Size + {2, 512}}); // Density + BENCHMARK_MAIN(); diff --git a/src/hb-set.hh b/src/hb-set.hh index de71e976f..b5ca07de8 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -43,8 +43,8 @@ struct hb_sparseset_t hb_sparseset_t (const hb_sparseset_t& other) : hb_sparseset_t () { set (other); } hb_sparseset_t (hb_sparseset_t&& other) : hb_sparseset_t () { s = std::move (other.s); } - hb_sparseset_t& operator= (const hb_sparseset_t& other) { set (other); return *this; } - hb_sparseset_t& operator= (hb_sparseset_t&& other) { s = std::move (other.s); return *this; } + hb_sparseset_t& operator = (const hb_sparseset_t& other) { set (other); return *this; } + hb_sparseset_t& operator = (hb_sparseset_t&& other) { s = std::move (other.s); return *this; } friend void swap (hb_sparseset_t& a, hb_sparseset_t& b) { hb_swap (a.s, b.s); } hb_sparseset_t (std::initializer_list lst) : hb_sparseset_t () @@ -169,8 +169,8 @@ struct hb_set_t : hb_sparseset_t hb_set_t (std::nullptr_t) : hb_set_t () {}; hb_set_t (const hb_set_t &o) : sparseset ((sparseset &) o) {}; hb_set_t (hb_set_t&& o) : sparseset (std::move ((sparseset &) o)) {} - hb_set_t& operator= (const hb_set_t&) = default; - hb_set_t& operator= (hb_set_t&&) = default; + hb_set_t& operator = (const hb_set_t&) = default; + hb_set_t& operator = (hb_set_t&&) = default; hb_set_t (std::initializer_list lst) : sparseset (lst) {} template