File tree Expand file tree Collapse file tree
include/boost/openmethod/policies Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,15 +111,13 @@ void fast_perfect_hash<Policy>::hash_initialize(
111111 }
112112 }
113113
114- bool found = false ;
115114 std::size_t attempts = 0 ;
116115 buckets.resize (hash_size);
117116
118- while (!found && attempts < 100000 ) {
117+ while (attempts < 100000 ) {
119118 std::fill (buckets.begin (), buckets.end (), static_cast <type_id>(-1 ));
120119 ++attempts;
121120 ++total_attempts;
122- found = true ;
123121 hash_mult = uniform_dist (rnd) | 1 ;
124122
125123 for (auto iter = first; iter != last; ++iter) {
@@ -131,16 +129,13 @@ void fast_perfect_hash<Policy>::hash_initialize(
131129 hash_max = (std::max)(hash_max, index);
132130
133131 if (buckets[index] != static_cast <type_id>(-1 )) {
134- found = false ;
135- break ;
132+ goto collision;
136133 }
137134
138135 buckets[index] = type;
139136 }
140137 }
141- }
142138
143- if (found) {
144139 if constexpr (trace_enabled) {
145140 if (Policy::trace_enabled) {
146141 Policy::trace_stream << " found " << hash_mult << " after "
@@ -151,6 +146,8 @@ void fast_perfect_hash<Policy>::hash_initialize(
151146 }
152147
153148 return ;
149+
150+ collision: {}
154151 }
155152 }
156153
You can’t perform that action at this time.
0 commit comments