<commit_before>#include "../common.c"
#include "m-dict.h"

static inline bool oor_equal_p(unsigned int k, unsigned char n)
{
  return k == (unsigned int)n;
}
static inline void oor_set(unsigned int *k, unsigned char n)
{
  *k = (unsigned int)n;
}

DICT_OA_DEF2(dict_oa_uint,
	     unsigned int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)),
	     unsigned int, M_DEFAULT_OPLIST)

void test_int(uint32_t n, uint32_t x0)
{
  uint32_t i, x, z = 0;
  dict_oa_uint_t h;
  dict_oa_uint_init(h);
  for (i = 0, x = x0; i < n; ++i) {
    x = hash32(x);
    unsigned int key = get_key(n, x);
    unsigned int *ptr = dict_oa_uint_get(h, key);
    if (ptr) { (*ptr)++; z+= *ptr; }
    else { dict_oa_uint_set_at(h, key, 1); z+=1; }
  }
  fprintf(stderr, "# unique keys: %d; checksum: %u\n", (int) dict_oa_uint_size(h), z);
  dict_oa_uint_clear(h);
}<commit_msg>Simplify code to use get_at method with its get & create semantic<commit_after>#include "../common.c"
#include "m-dict.h"

static inline bool oor_equal_p(unsigned int k, unsigned char n)
{
  return k == (unsigned int)n;
}
static inline void oor_set(unsigned int *k, unsigned char n)
{
  *k = (unsigned int)n;
}

DICT_OA_DEF2(dict_oa_uint,
	     unsigned int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)),
	     unsigned int, M_DEFAULT_OPLIST)

void test_int(uint32_t n, uint32_t x0)
{
  uint32_t i, x, z = 0;
  dict_oa_uint_t h;
  dict_oa_uint_init(h);
  for (i = 0, x = x0; i < n; ++i) {
    x = hash32(x);
    unsigned int key = get_key(n, x);
    unsigned int *ptr = dict_oa_uint_get_at(h, key);
    (*ptr)++;
    z+= *ptr;
  }
  fprintf(stderr, "# unique keys: %d; checksum: %u\n", (int) dict_oa_uint_size(h), z);
  dict_oa_uint_clear(h);
}
{'fraction_non_alphanumeric': 0.14724275156338829, 'fraction_numerical': 0.015918135304150087, 'mean_word_length': 4.072046109510087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1512271', 'n_tokens_mistral': 771, 'n_tokens_neox': 747, 'n_words': 187}