Skip to content

Commit 3feeede

Browse files
authored
Optimize hash lookup by breaking early on empty buckets for cpu bbs3d (#54)
1 parent 2155daf commit 3feeede

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bbs3d/src/cpu_bbs3d/bbs3d.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,16 @@ void BBS3D::calc_score(
153153
const std::uint32_t bucket_index = (hash + j) % num_buckets;
154154
const Eigen::Vector4i& bucket = buckets[bucket_index];
155155

156+
if (bucket.w() == 0) {
157+
break;
158+
}
159+
156160
if (bucket.x() != coord.x() || bucket.y() != coord.y() || bucket.z() != coord.z()) {
157161
continue;
158162
}
159163

160-
if (bucket.w() == 1) {
161-
trans.score++;
162-
break;
163-
}
164+
trans.score++;
165+
break;
164166
}
165167
}
166168
}
@@ -255,4 +257,4 @@ void BBS3D::localize() {
255257
has_localized_ = true;
256258
}
257259

258-
} // namespace cpu
260+
} // namespace cpu

0 commit comments

Comments
 (0)