<commit_before>/*
 * hashrs.c, part of "klib" project.
 *
 *  Created on: 24.05.2015, 03:30
 *      Author: <NAME> <<EMAIL>>
 */

#include "hash.h"

#define A   63689
#define B   378551

static unsigned a = 0;

unsigned hash_rs( unsigned startval, const void * buf, size_t size )
{
    unsigned hash;

    if( !startval ) a = A;
    for( hash = startval; size; size--, (unsigned char *)buf++ )
    {
        hash = hash * a + *((unsigned char *)buf);
        a *= B;
    }
    return hash;
}

unsigned shash_rs( unsigned startval, const char * buf )
{
    unsigned hash;

    if( !startval ) a = A;
    for( hash = startval; *buf; buf++ )
    {
        hash = hash * a + *((unsigned char *)buf);
        a *= B;
    }
    return hash;
}
<commit_msg>hide static var<commit_after>/*
 * hashrs.c, part of "klib" project.
 *
 *  Created on: 24.05.2015, 03:30
 *      Author: <NAME> <<EMAIL>>
 */

#include "hash.h"

#define A   63689
#define B   378551

unsigned hash_rs( unsigned startval, const void * buf, size_t size )
{
    static unsigned a = 0;
    unsigned hash;

    if( !startval ) a = A;
    for( hash = startval; size; size--, (unsigned char *)buf++ )
    {
        hash = hash * a + *((unsigned char *)buf);
        a *= B;
    }
    return hash;
}

unsigned shash_rs( unsigned startval, const char * buf )
{
    return hash_rs( startval, buf, strlen(buf) );
}

{'fraction_non_alphanumeric': 0.14963503649635038, 'fraction_numerical': 0.035036496350364967, 'mean_word_length': 2.376847290640394, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1574801', 'n_tokens_mistral': 531, 'n_tokens_neox': 493, 'n_words': 158}