HashedString.cpp 627 B

12345678910111213141516171819202122232425
  1. #include "common/utils/HashedString.h"
  2. HashedString::HashedString(const char* str) : length(0), hash(0) {
  3. for(; length < LENGTH - 1 && str[length] != '\0'; length++) {
  4. data[length] = str[length];
  5. hash = hash * 257 + str[length];
  6. }
  7. data[length] = '\0';
  8. }
  9. bool HashedString::operator==(const HashedString& other) const {
  10. return hash == other.hash && length == other.length;
  11. }
  12. bool HashedString::operator!=(const HashedString& other) const {
  13. return !(*this == other);
  14. }
  15. HashedString::operator const char*() const {
  16. return data;
  17. }
  18. u32 HashedString::hashCode() const {
  19. return hash;
  20. }