cmPathLabel.cxx 825 B

12345678910111213141516171819202122232425262728
  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. cmPathLabel::cmPathLabel(const std::string& label)
  5. : Label(label)
  6. , Hash(0)
  7. {
  8. // Use a Jenkins one-at-a-time hash with under/over-flow protection
  9. for (char i : this->Label) {
  10. this->Hash += i;
  11. this->Hash += ((this->Hash & 0x003FFFFF) << 10);
  12. this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
  13. }
  14. this->Hash += ((this->Hash & 0x1FFFFFFF) << 3);
  15. this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11);
  16. this->Hash += ((this->Hash & 0x0001FFFF) << 15);
  17. }
  18. bool cmPathLabel::operator<(const cmPathLabel& l) const
  19. {
  20. return this->Hash < l.Hash;
  21. }
  22. bool cmPathLabel::operator==(const cmPathLabel& l) const
  23. {
  24. return this->Hash == l.Hash;
  25. }