<commit_before>#include "ll.h"

#include <stdlib.h>

void
ll_destroy(
    struct ll* ll
) {
    struct ll_element* iter = ll->head;
    struct ll_element* next;

    while (iter) {
        next = iter->next;
        free(iter);
        iter = next;
    }
}

struct ll*
ll_insert(
    struct ll* ll,
    struct ll_element* e
) {
    if (!ll || !e) {
        return NULL;
    }

    e->next = ll->head;
    ll->head = e;
    return ll;
}

struct ll*
ll_insert_data(
    struct ll* ll,
    void* data
) {
    struct ll_element* el = ll_element_alloc_new(data);
    return ll_insert(ll, el);
}

struct ll*
ll_delete(
    struct ll* ll,
    struct ll_element* del
) {
    struct ll_element* iter;
    struct ll_element* last;

    for (iter = ll->head; iter; iter = iter->next) {
        if (iter == del) {
            if (iter == ll->head) {
                ll->head = iter->next;
            } else {
                last->next = iter->next;
            }
            free(iter);<commit_msg>Updated implementation: Don't check the HEAD in the iteration<commit_after>#include "ll.h"

#include <stdlib.h>

void
ll_destroy(
    struct ll* ll
) {
    struct ll_element* iter = ll->head;
    struct ll_element* next;

    while (iter) {
        next = iter->next;
        free(iter);
        iter = next;
    }
}

struct ll*
ll_insert(
    struct ll* ll,
    struct ll_element* e
) {
    if (!ll || !e) {
        return NULL;
    }

    e->next = ll->head;
    ll->head = e;
    return ll;
}

struct ll*
ll_insert_data(
    struct ll* ll,
    void* data
) {
    struct ll_element* el = ll_element_alloc_new(data);
    return ll_insert(ll, el);
}

struct ll*
ll_delete(
    struct ll* ll,
    struct ll_element* del
) {
    struct ll_element* iter;
    struct ll_element* last;

    if (del == ll->head) {
        iter = ll->head;
        ll->head = ll->head->next;
        free(iter);
        return ll;
    }

    for (iter = ll->head; iter; iter = iter->next) {
        if (iter == del) {
            last->next = iter->next;
            free(iter);
{'fraction_non_alphanumeric': 0.13509544787077826, 'fraction_numerical': 0.0, 'mean_word_length': 1.9241773962804005, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '303968', 'n_tokens_mistral': 728, 'n_tokens_neox': 714, 'n_words': 193}