<commit_before>#include <Foundation/Foundation.h>
#include <string>

bool UrlDownload(const std::string& url, double timeout, std::string& errorMessage) {
    NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:nsurl cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:timeout];
    request.HTTPMethod = @"HEAD";
    __block bool success = false;
    __block bool done = false;
    NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data __unused, NSURLResponse *response, NSError *error) {
        if (error) {
            errorMessage.assign(error.localizedDescription.UTF8String);
        } else {
            NSHTTPURLResponse *httpresponse = (NSHTTPURLResponse*)response;
            const NSInteger code = httpresponse.statusCode;
            if (code != 200) {
                errorMessage.assign([NSString stringWithFormat:@"HTTP Status %ld", code].UTF8String);
            } else {
                success = true;
            }
        }
        done = true;
    }];
    [task resume];
    while (!done) {
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
    }
    return success;
}
<commit_msg>Move handler to a variable<commit_after>#include <Foundation/Foundation.h>
#include <string>

bool UrlDownload(const std::string& url, double timeout, std::string& errorMessage) {
    NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:nsurl cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:timeout];
    request.HTTPMethod = @"HEAD";
    __block bool success = false;
    __block bool done = false;
    void (^handler)(NSData *, NSURLResponse *, NSError *) = ^(NSData *data __unused, NSURLResponse *response, NSError *error) {
        if (error) {
            errorMessage.assign(error.localizedDescription.UTF8String);
        } else {
            NSHTTPURLResponse *httpresponse = (NSHTTPURLResponse*)response;
            const NSInteger code = httpresponse.statusCode;
            if (code != 200) {
                errorMessage.assign([NSString stringWithFormat:@"HTTP Status %ld", code].UTF8String);
            } else {
                success = true;
            }
        }
        done = true;
    };
    [[session dataTaskWithRequest:request completionHandler:handler] resume];
    while (!done) {
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
    }
    return success;
}

{'fraction_non_alphanumeric': 0.10120068610634649, 'fraction_numerical': 0.005488850771869639, 'mean_word_length': 3.5849056603773586, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6671342', 'n_tokens_mistral': 818, 'n_tokens_neox': 786, 'n_words': 172}