| 2716 | } |
| 2717 | |
| 2718 | uint32_t String::hash(const char *p_cstr) { |
| 2719 | // static_cast: avoid negative values on platforms where char is signed. |
| 2720 | uint32_t hashv = 5381; |
| 2721 | uint32_t c = static_cast<uint8_t>(*p_cstr++); |
| 2722 | |
| 2723 | while (c) { |
| 2724 | hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */ |
| 2725 | c = static_cast<uint8_t>(*p_cstr++); |
| 2726 | } |
| 2727 | |
| 2728 | return hashv; |
| 2729 | } |
| 2730 | |
| 2731 | uint32_t String::hash(const char *p_cstr, int p_len) { |
| 2732 | uint32_t hashv = 5381; |
no test coverage detected