<commit_before>#include "utils.h"

void insert(int* target_array, int* source_array, int size, int origin, int target) {
    int t_i = 0;
    int s_i = 0;
    for (int i = 0; i < size; i++) {
        if (origin == target || target == origin + 1) {
            target_array[t_i] = source_array[s_i];
        } else if (s_i == target) {
            target_array[t_i]   = source_array[origin];
            t_i = (t_i + 1) % size;
            target_array[t_i] = source_array[target];
        } else if (i == origin) {
            s_i = (s_i + 1) % size;
            target_array[t_i] = source_array[s_i];
        } else {
            target_array[t_i] = source_array[s_i];
        }
        t_i++;
        s_i++;<commit_msg>*drumroll*: insert function fix 	added better handling of useless insert requests (origin = target or target is right after origin) 	when checking whether we've reached the origin in the source array, USE THE SOURCE ARRAY INDEX!!! (and not the loop index)<commit_after>#include "utils.h"

void insert(int* target_array, int* source_array, int size, int origin, int target) {
    // if this is a stupid request
    if (origin == target || target == origin + 1) {
        ARRAY_COPY(target_array, source_array, size);
        return;
    }
    
    // if it is a sensible request
    int t_i = 0;
    int s_i = 0;
    for (int i = 0; i < size; i++) {
        if (s_i == target) {
            target_array[t_i] = source_array[origin];
            t_i = (t_i + 1) % size;
            target_array[t_i] = source_array[target];
        } else if (s_i == origin) {
            s_i = (s_i + 1) % size;
            target_array[t_i] = source_array[s_i];
        } else {
            target_array[t_i] = source_array[s_i];
        }
        t_i++;
        s_i++;
{'fraction_non_alphanumeric': 0.12464749012972363, 'fraction_numerical': 0.00676818950930626, 'mean_word_length': 2.112280701754386, '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': '6763273', 'n_tokens_mistral': 615, 'n_tokens_neox': 598, 'n_words': 173}