<commit_before>//
//  Array.c
//  xcxc
//
//  Created by <NAME> on 7/22/13.
//
//

#include "Array.h"
#include <stdlib.h>
#include <memory.h>

Array *_arr_new()
{
    Array *arr=malloc(sizeof(Array));
    arr->count=0;
    arr->capacity=4;
    arr->items=malloc(sizeof(void *)*4);
    return arr;
}

void _arr_delete(Array *arr,void (*handler)(void *ob))
{
    for(int i=0;i<arr->count;++i)
    {
        if(handler)
            handler(arr->items[i]);
//        free(arr->items[i]);
    }
    free(arr->items);
    free(arr);
}

void _arr_add(Array *arr,void *ob)
{
    if(arr->count==arr->capacity)
    {
        arr->capacity*=2;
        arr->items=realloc(arr->items,arr->capacity*sizeof(void *));
    }
    
    arr->items[arr->count]=ob;
    ++arr->count;
}

void _arr_remove(Array *arr,int pos,int length,void (*handler)(void *ob))
{
    if(handler)
    {
        for(int i=pos;i<pos+length;++i)
        {
            handler(arr->items[i]);
//            free(arr->items[i]);
        }
    }else
    {
        for(int i=pos;i<pos+length;++i)
        {
//            free(arr->items[i]);
        }
    }
    
    memmove(&arr->items[pos],&arr->items[pos+length],(arr->count-pos-length)*sizeof(void *));
    arr->count-=length;
}

void *_arr_get(Array *arr,int pos)
{
    return arr->items[pos];
}<commit_msg>Cleanup, slight performance increase<commit_after>//
//  Array.c
//  xcxc
//
//  Created by <NAME> on 7/22/13.
//
//

#include "Array.h"
#include <stdlib.h>
#include <memory.h>

Array *_arr_new()
{
    Array *arr=malloc(sizeof(Array));
    arr->count=0;
    arr->capacity=4;
    arr->items=malloc(sizeof(void *)*4);
    return arr;
}

void _arr_delete(Array *arr,void (*handler)(void *ob))
{
    if(handler)
    {
        for(int i=0;i<arr->count;++i)
        {
            if(handler)
                handler(arr->items[i]);
        }
    }
    free(arr->items);
    free(arr);
}

void _arr_add(Array *arr,void *ob)
{
    if(arr->count==arr->capacity)
    {
        arr->capacity*=2;
        arr->items=realloc(arr->items,arr->capacity*sizeof(void *));
    }
    
    arr->items[arr->count]=ob;
    ++arr->count;
}

void _arr_remove(Array *arr,int pos,int length,void (*handler)(void *ob))
{
    if(handler)
    {
        for(int i=pos;i<pos+length;++i)
        {
            handler(arr->items[i]);
        }
    }
    
    memmove(&arr->items[pos],&arr->items[pos+length],(arr->count-pos-length)*sizeof(void *));
    arr->count-=length;
}

void *_arr_get(Array *arr,int pos)
{
    return arr->items[pos];
}
{'fraction_non_alphanumeric': 0.20483359746434232, 'fraction_numerical': 0.00792393026941363, 'mean_word_length': 2.4260515603799186, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 54, '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': '5458504', 'n_tokens_mistral': 983, 'n_tokens_neox': 964, 'n_words': 136}