<commit_before>//
//  Ashton.swift
//  Ashton
//
//  Created by <NAME> on 16.09.17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import Ashton.AshtonObjc

/// Transforms AttributedString into HTML in both directions
public final class Ashton {

	public typealias HTML = String

	public static func encode(_ attributedString: NSAttributedString) -> HTML {
		return AshtonHTMLWriter().encode(attributedString)
	}

	public static func decode(_ html: HTML) -> NSAttributedString {
        //return AshtonObjcHTMLReader().decodeAttributedString(fromHTML: html)
		return AshtonHTMLReader().decode(html) // swift implementation
	}
}
<commit_msg>Use objc implementation for decoding<commit_after>//
//  Ashton.swift
//  Ashton
//
//  Created by <NAME> on 16.09.17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Foundation
import Ashton.AshtonObjc

/// Transforms AttributedString into HTML in both directions
public final class Ashton {

	public typealias HTML = String

	public static func encode(_ attributedString: NSAttributedString) -> HTML {
		return AshtonHTMLWriter().encode(attributedString)
	}

	public static func decode(_ html: HTML) -> NSAttributedString {
        return AshtonObjcHTMLReader().decodeAttributedString(fromHTML: html)

		// swift implementation is substantially slower (using swift4 to compile)
        // return AshtonHTMLReader().decode(html) // swift implementation
	}
}

{'fraction_non_alphanumeric': 0.09881697981906751, 'fraction_numerical': 0.014613778705636743, 'mean_word_length': 3.907849829351536, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6916231', 'n_tokens_mistral': 454, 'n_tokens_neox': 396, 'n_words': 127}