/src/CMake/Source/cmPathLabel.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #include "cmPathLabel.h" |
4 | | |
5 | | #include <utility> |
6 | | |
7 | | cmPathLabel::cmPathLabel(std::string label) |
8 | 48 | : Label(std::move(label)) |
9 | 48 | , Hash(0) |
10 | 48 | { |
11 | | // Use a Jenkins one-at-a-time hash with under/over-flow protection |
12 | 568 | for (char i : this->Label) { |
13 | 568 | this->Hash += i; |
14 | 568 | this->Hash += ((this->Hash & 0x003FFFFF) << 10); |
15 | 568 | this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6); |
16 | 568 | } |
17 | 48 | this->Hash += ((this->Hash & 0x1FFFFFFF) << 3); |
18 | 48 | this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11); |
19 | 48 | this->Hash += ((this->Hash & 0x0001FFFF) << 15); |
20 | 48 | } |
21 | | |
22 | | bool cmPathLabel::operator<(cmPathLabel const& l) const |
23 | 0 | { |
24 | 0 | return this->Hash < l.Hash; |
25 | 0 | } |
26 | | |
27 | | bool cmPathLabel::operator==(cmPathLabel const& l) const |
28 | 0 | { |
29 | 0 | return this->Hash == l.Hash; |
30 | 0 | } |