<commit_before>//
// String+Indent.swift
//
// Copyright (c) 2015 <NAME>
//
// Licensed under the MIT license. For full copyright and license information,
// please see the LICENSE file.
//

import Foundation

extension String {
    /// Indents every line with prefix.
    public func indent(prefix: String = "  ") -> String {
        let lines = split(characters) { $0 == "\n" }
        
        var result = String()
        result.reserveCapacity(characters.count + lines.count * prefix.characters.count)

        // $1 is String.CharacterView
        result = lines.reduce(result) { $0 + prefix + String($1) + "\n" }
        
        return result
    }
}<commit_msg>Optimize indentation in debug output<commit_after>//
// String+Indent.swift
//
// Copyright (c) 2015 <NAME>
//
// Licensed under the MIT license. For full copyright and license information,
// please see the LICENSE file.
//

import Foundation

extension String {
    /// Indents every line with prefix.
    public func indent(prefix: String = "  ") -> String {
        let lines = split(characters) { $0 == "\n" }
        
        var result = String()
        result.reserveCapacity(characters.count + lines.count * prefix.characters.count)

        // $1 is String.CharacterView
        //result = lines.reduce(result) { $0 + prefix + String($1) + "\n" }
        // Optimized:
        for line in lines {
            result += prefix
            result += String(line)
            result += "\n"
        }
        
        return result
    }
}
{'fraction_non_alphanumeric': 0.12648221343873517, 'fraction_numerical': 0.010540184453227932, 'mean_word_length': 2.0686868686868687, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4995281', 'n_tokens_mistral': 433, 'n_tokens_neox': 418, 'n_words': 131}