<commit_before><?php

use AnhNhan\Converge\Modules\User\Query\UserQuery;

function create_user_query($app_or_em)
{
    return new UserQuery($app_or_em);
}

function fetch_external_authors(array $stuff, UserQuery $query, $id_field = 'authorId', $set_method = 'setAuthor', $author_field = 'author')
{
    if (empty($stuff))
    {
        return;
    }
    if (count(array_filter(mpull($stuff, $author_field))) == count($stuff))
    {
        return;
    }

    $user_ids = mpull($stuff, $id_field);
    $users = $query->retrieveUsersForUIDs($user_ids);
    foreach ($stuff as $thing)
    {
        $thing->$set_method(idx($users, $thing->$id_field));
    }
}<commit_msg>Minor optimization<commit_after><?php

use AnhNhan\Converge\Modules\User\Query\UserQuery;

function create_user_query($app_or_em)
{
    return new UserQuery($app_or_em);
}

function fetch_external_authors(array $stuff, UserQuery $query, $id_field = 'authorId', $set_method = 'setAuthor', $author_field = 'author')
{
    if (empty($stuff))
    {
        return;
    }
    if (count(array_filter(mpull($stuff, $author_field))) == count($stuff))
    {
        return;
    }

    $user_ids = mpull($stuff, $id_field);
    $user_ids = array_unique($user_ids);
    $users = $query->retrieveUsersForUIDs($user_ids);
    foreach ($stuff as $thing)
    {
        $thing->$set_method(idx($users, $thing->$id_field));
    }
}
{'fraction_non_alphanumeric': 0.15918958031837915, 'fraction_numerical': 0.0, 'mean_word_length': 3.8869257950530036, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6200767', 'n_tokens_mistral': 506, 'n_tokens_neox': 492, 'n_words': 79}