2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2014-10-17 21:07:26 +04:00
|
|
|
#include "cmPathLabel.h"
|
|
|
|
|
|
|
|
cmPathLabel::cmPathLabel(const std::string& label)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Label(label)
|
|
|
|
, Hash(0)
|
2014-10-17 21:07:26 +04:00
|
|
|
{
|
|
|
|
// Use a Jenkins one-at-a-time hash with under/over-flow protection
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < this->Label.size(); ++i) {
|
2014-10-17 21:07:26 +04:00
|
|
|
this->Hash += this->Label[i];
|
|
|
|
this->Hash += ((this->Hash & 0x003FFFFF) << 10);
|
|
|
|
this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-10-17 21:07:26 +04:00
|
|
|
this->Hash += ((this->Hash & 0x1FFFFFFF) << 3);
|
|
|
|
this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11);
|
|
|
|
this->Hash += ((this->Hash & 0x0001FFFF) << 15);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmPathLabel::operator<(const cmPathLabel& l) const
|
2014-10-17 21:07:26 +04:00
|
|
|
{
|
|
|
|
return this->Hash < l.Hash;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmPathLabel::operator==(const cmPathLabel& l) const
|
2014-10-17 21:07:26 +04:00
|
|
|
{
|
|
|
|
return this->Hash == l.Hash;
|
|
|
|
}
|