#include "common/utils/HashedString.h"

HashedString::HashedString() : length(0), hash(0) {
    data[length] = '\0';
}

HashedString::HashedString(const char* str) : length(0), hash(0) {
    for(; length < LENGTH - 1 && str[length] != '\0'; length++) {
        data[length] = str[length];
        hash = hash * 257 + str[length];
    }
    data[length] = '\0';
}

bool HashedString::operator==(const HashedString& other) const {
    return hash == other.hash && length == other.length;
}

bool HashedString::operator!=(const HashedString& other) const {
    return !(*this == other);
}

HashedString::operator const char*() const {
    return data;
}

u32 HashedString::hashCode() const {
    return hash;
}