Skip to content

Commit 63c59a9

Browse files
authored
hash_pair fix (#227)
* fix: hash_pair function * linter report * ci: update artifact * ci: fix action * CI: update macos version to 14
1 parent 0f2b799 commit 63c59a9

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
run: cmake --build ${{ env.build_dir }}
5050

5151
- name: Upload binary
52-
uses: actions/upload-artifact@v2
52+
uses: actions/upload-artifact@v4
5353
with:
54-
name: ${{env.artifact}}
54+
name: windows-${{env.artifact}}
5555
path: ${{env.build_dir}}/spla_x64.dll
5656

5757

@@ -75,13 +75,13 @@ jobs:
7575
run: cmake --build ${{ env.build_dir }}
7676

7777
- name: Upload binary
78-
uses: actions/upload-artifact@v2
78+
uses: actions/upload-artifact@v4
7979
with:
80-
name: ${{env.artifact}}
80+
name: linux-${{env.artifact}}
8181
path: ${{env.build_dir}}/libspla_x64.so
8282

8383
macos:
84-
runs-on: macos-11
84+
runs-on: macos-14
8585
steps:
8686
- uses: actions/checkout@v2
8787
with:
@@ -105,9 +105,9 @@ jobs:
105105
run: cmake --build ${{ env.build_dir }}
106106

107107
- name: Upload binary
108-
uses: actions/upload-artifact@v2
108+
uses: actions/upload-artifact@v4
109109
with:
110-
name: ${{env.artifact}}
110+
name: macos-${{env.artifact}}
111111
path: |
112112
${{env.build_dir}}/libspla_x64.dylib
113113
${{env.build_dir}}/libspla_arm64.dylib

src/util/pair_hash.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ namespace spla {
3737
* @{
3838
*/
3939

40+
template<class T>
41+
inline void hash_combine(std::size_t& seed, const T& v) {
42+
std::hash<T> hasher;
43+
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
44+
}
45+
4046
struct pair_hash {
4147
public:
4248
template<typename T, typename U>
4349
std::size_t operator()(const std::pair<T, U>& x) const {
44-
return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
50+
std::size_t seed = 0;
51+
hash_combine(seed, x.first);
52+
hash_combine(seed, x.second);
53+
return seed;
4554
}
4655
};
4756

0 commit comments

Comments
 (0)