static_inline bool ptr_token_eq()

in include/yyjson/yyjson.c [1920:1937]


static_inline bool ptr_token_eq(void *key,
                                const char *token, usize len, usize esc) {
    yyjson_val *val = (yyjson_val *)key;
    if (unsafe_yyjson_get_len(val) != len) return false;
    if (likely(!esc)) {
        return memcmp(val->uni.str, token, len) == 0;
    } else {
        const char *str = val->uni.str;
        for (; len-- > 0; token++, str++) {
            if (*token == '~') {
                if (*str != (*++token == '0' ? '~' : '/')) return false;
            } else {
                if (*str != *token) return false;
            }
        }
        return true;
    }
}