<commit_before>#include "fitz_base.h"
#include "fitz_stream.h"

/* keep either names or strings in the dict. don't mix & match. */

static int keyvalcmp(const void *ap, const void *bp)
{
	const fz_keyval *a = ap;
	const fz_keyval *b = bp;
	if (fz_isname(a->k))
		return strcmp(fz_toname(a->k), fz_toname(b->k));
	if (fz_isstring(a->k))
		return strcmp(fz_tostrbuf(a->k), fz_tostrbuf(b->k));
	return -1;
}

static inline int keystrcmp(fz_obj *key, char *s)
{
	if (fz_isname(key))
		return strcmp(fz_toname(key), s);
	if (fz_isstring(key))
		return strcmp(fz_tostrbuf(key), s);
	return -1;<commit_msg>Use memcmp to compare fz_obj strings which can contain embedded zeroes.<commit_after>#include "fitz_base.h"
#include "fitz_stream.h"

/* keep either names or strings in the dict. don't mix & match. */

static int keyvalcmp(const void *ap, const void *bp)
{
	const fz_keyval *a = ap;
	const fz_keyval *b = bp;
	if (fz_isname(a->k) && fz_isname(b->k))
		return strcmp(fz_toname(a->k), fz_toname(b->k));
	if (fz_isstring(a->k) && fz_isstring(b->k))
		if (fz_tostrlen(a->k) == fz_tostrlen(b->k))
			return memcmp(fz_tostrbuf(a->k), fz_tostrbuf(b->k), fz_tostrlen(a->k));
	return -1;
}

static inline int keystrcmp(fz_obj *key, char *s)
{
	if (fz_isname(key))
		return strcmp(fz_toname(key), s);
	if (fz_isstring(key))
		if (strlen(s) == fz_tostrlen(key))
			return memcmp(fz_tostrbuf(key), s, fz_tostrlen(key));
	return -1;
{'fraction_non_alphanumeric': 0.16713681241184766, 'fraction_numerical': 0.0028208744710860366, 'mean_word_length': 4.8879668049792535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6562731', 'n_tokens_mistral': 670, 'n_tokens_neox': 651, 'n_words': 143}