<commit_before>

#include "json.h"

#include <string.h>
#include <stdio.h>

const char *json_str(const char *str, char *buf, size_t len)
{
	size_t ix, bufix=0;

	// TODO: Check all bufix>len-n expressions for correctness
	if (bufix>len-2) return NULL;
	buf[bufix++]='"';
	for (ix=0; ix<strlen(str); ++ix) {<commit_msg>Optimize json_str()<commit_after>

#include "json.h"

#include <string.h>
#include <stdio.h>

const char *json_str(const char *str, char *buf, size_t len)
{
	size_t ix, bufix=0;
	size_t sl;

	sl=strlen(str);

	// TODO: Check all bufix>len-n expressions for correctness
	/*if (bufix>len-2) return NULL;*/
	buf[bufix++]='"';
	for (ix=0; ix<sl; ++ix) {
{'fraction_non_alphanumeric': 0.18140929535232383, 'fraction_numerical': 0.008995502248875561, 'mean_word_length': 4.758620689655173, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2685678', 'n_tokens_mistral': 291, 'n_tokens_neox': 280, 'n_words': 74}