@@ -94,7 +94,8 @@ struct partitioned_phf //
9494 m_num_keys = builder.num_keys ();
9595 m_table_size = builder.table_size ();
9696 m_partitioner = builder.bucketer ();
97- m_partitions.resize (num_partitions);
97+ std::vector<partition> partitions;
98+ partitions.resize (num_partitions);
9899
99100 auto const & offsets = builder.offsets ();
100101 auto const & builders = builder.builders ();
@@ -104,8 +105,8 @@ struct partitioned_phf //
104105 std::vector<std::thread> threads (num_threads);
105106 auto exe = [&](uint64_t begin, uint64_t end) {
106107 for (; begin != end; ++begin) {
107- m_partitions [begin].offset = offsets[begin];
108- m_partitions [begin].f .build (builders[begin], config);
108+ partitions [begin].offset = offsets[begin];
109+ partitions [begin].f .build (builders[begin], config);
109110 }
110111 };
111112
@@ -123,11 +124,13 @@ struct partitioned_phf //
123124 }
124125 } else {
125126 for (uint64_t i = 0 ; i != num_partitions; ++i) {
126- m_partitions [i].offset = offsets[i];
127- m_partitions [i].f .build (builders[i], config);
127+ partitions [i].offset = offsets[i];
128+ partitions [i].f .build (builders[i], config);
128129 }
129130 }
130131
132+ m_partitions = std::move (partitions);
133+
131134 auto stop = clock_type::now ();
132135
133136 return to_microseconds (stop - start);
@@ -147,7 +150,7 @@ struct partitioned_phf //
147150
148151 uint64_t num_bits_for_pilots () const {
149152 uint64_t bits = 8 * (sizeof (m_seed) + sizeof (m_num_keys) + sizeof (m_table_size) +
150- sizeof (uint64_t ) // for std::vector:: size
153+ sizeof (uint64_t ) // for span's size
151154 ) +
152155 m_partitioner.num_bits ();
153156 for (auto const & p : m_partitions) bits += 8 * sizeof (p.offset ) + p.f .num_bits_for_pilots ();
@@ -200,7 +203,7 @@ struct partitioned_phf //
200203 uint64_t m_num_keys;
201204 uint64_t m_table_size;
202205 range_bucketer m_partitioner;
203- std::vector <partition> m_partitions;
206+ essentials::owning_span <partition> m_partitions;
204207};
205208
206209} // namespace pthash
0 commit comments