Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse location hash check logic #912

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
- Update formatting script to use `clang-format` 14 (#894)
- Setup a `clang-tidy` workflow (#789)

### Fixed

- Internal matrix problem with inconsistent `location_index` and `location` values (#909)

## [v1.13.0] - 2023-01-31

### Added
Expand Down
13 changes: 7 additions & 6 deletions src/structures/vroom/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ class Location {
namespace std {
template <> struct hash<vroom::Location> {
std::size_t operator()(const vroom::Location& l) const noexcept {
if (l.has_coordinates()) {
return ((hash<vroom::Coordinate>()(l.lon()) ^
(hash<vroom::Coordinate>()(l.lat()) << 1)) >>
1);
if (l.user_index()) {
return hash<vroom::Index>()(l.index());
}
assert(l.user_index());
return hash<vroom::Index>()(l.index());

assert(l.has_coordinates());
return ((hash<vroom::Coordinate>()(l.lon()) ^
(hash<vroom::Coordinate>()(l.lat()) << 1)) >>
1);
}
};
} // namespace std
Expand Down