<commit_before>#include <stdlib.h>
#include <string.h>

#include <pthread.h>

#include "hashtable.h"
#include "list.h"

struct hashtable_s {
    size_t          elements;
    size_t          size;
    pthread_mutex_t mutex;
    list_t        **table;
};

static inline size_t hashtable_pot(size_t size) {
    size--;
    size |= size >> 1;
    size |= size >> 2;
    size |= size >> 8;
    size |= size >> 16;

    /* for 64 bit size_t */
    if (sizeof(size_t) == 8)
        size |= size >> 32;

    size++;
    return size;
}

static inline size_t hashtable_hash(const char *string) {
    size_t hash   = 0;<commit_msg>Fix constant expression warning where sizeof(size_t) != 8. On hosts where sizeof(size_t) != 8 the shift value is too large. The code for the shift will only take place where sizeof(size_t) == 8, however the compiler still considers the branch to be taken. Code like this could be acomplished with something akin to 'static if'. The solution is to take advantage of fact that where sizeof(size_t) == 8, the expression (sizeof(size_t) * 4) will produce 32 and on systems where that is not the case, the expression will produce a constant value well within the shift range for size_t.<commit_after>#include <stdlib.h>
#include <string.h>

#include <pthread.h>

#include "hashtable.h"
#include "list.h"

struct hashtable_s {
    size_t          elements;
    size_t          size;
    pthread_mutex_t mutex;
    list_t        **table;
};

static inline size_t hashtable_pot(size_t size) {
    size--;
    size |= size >> 1;
    size |= size >> 2;
    size |= size >> 8;
    size |= size >> 16;

    if (sizeof(size_t) == 8)
        size |= size >> (sizeof(size_t) * 4); /* to prevent a warning where sizeof(size_t) != 8 */

    return size + 1;
}

static inline size_t hashtable_hash(const char *string) {
    size_t hash   = 0;
{'fraction_non_alphanumeric': 0.11165311653116532, 'fraction_numerical': 0.015176151761517615, 'mean_word_length': 2.902748414376321, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '4754932', 'n_tokens_mistral': 635, 'n_tokens_neox': 591, 'n_words': 216}