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