<commit_before>//  Created by <NAME> on 2016/7/18.
//  Copyright © 2019 DingSoung. All rights reserved.

#if canImport(SystemConfiguration)
import SystemConfiguration

extension SCNetworkReachability {
    public typealias UpdateBlock = @convention(block) (SCNetworkReachability) -> Void

    private static let association = Association<NSMapTable<NSString, AnyObject>>()
    private var blocks: NSMapTable<NSString, AnyObject> {
        return SCNetworkReachability.association[self] ?? NSMapTable(keyOptions: .weakMemory, valueOptions: .weakMemory)
    }

    public func addObserve(uid: String, updateBlock: @escaping UpdateBlock) {
        let object = unsafeBitCast(updateBlock, to: AnyObject.self)
        self.blocks.setObject(object, forKey: uid as NSString)
    }

    public func removeObserve(uid: String) {
        self.blocks.removeObject(forKey: uid as NSString)
    }

    @discardableResult
    public func start() -> Bool {
        var context = SCNetworkReachabilityContext(version: 0,
                                                   info: UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque()),
                                                   retain: nil,
                                                   release: nil,
                                                   copyDescription: nil)
        let callback: SCNetworkReachabilityCallBack = { _, _, info in
            guard let info = info else {
                return
            }
            let networkReachability = Unmanaged<SCNetworkReachability>.fromOpaque(info).takeUnretainedValue() as SCNetworkReachability
            let enumerator = networkReachability.blocks.objectEnumerator()
            while let object: AnyObject = enumerator?.nextObject() as AnyObject? {
                let block = unsafeBitCast(object, to: UpdateBlock.self)
                block(networkReachability)
            }
        }
        return SCNetworkReachabilitySetCallback(self, callback, &context)
            && SCNetworkReachabilityScheduleWithRunLoop(self, CFRunLoopGetCurrent(), CFRunLoopMode.defaultMode.rawValue)
    }
<commit_msg>check build<commit_after>//  Created by <NAME> on 2016/7/18.
//  Copyright © 2019 DingSoung. All rights reserved.

#if canImport(SystemConfiguration)
import SystemConfiguration

extension SCNetworkReachability {
    public typealias UpdateBlock = @convention(block) (SCNetworkReachability) -> Void

    private static let association = Association<NSMapTable<NSString, AnyObject>>()
    private var blocks: NSMapTable<NSString, AnyObject> {
        return SCNetworkReachability.association[self] ?? NSMapTable(keyOptions: .weakMemory, valueOptions: .weakMemory)
    }

    public func addObserve(uid: String, updateBlock: @escaping UpdateBlock) {
        let object = unsafeBitCast(updateBlock, to: AnyObject.self)
        self.blocks.setObject(object, forKey: uid as NSString)
    }

    public func removeObserve(uid: String) {
        self.blocks.removeObject(forKey: uid as NSString)
    }

    @discardableResult
    public func start() -> Bool {
        let info = UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
        var context = SCNetworkReachabilityContext(version: 0,
                                                   info: info,
                                                   retain: nil,
                                                   release: nil,
                                                   copyDescription: nil)
        let callback: SCNetworkReachabilityCallBack = { _, _, info in
            guard let info = info else {
                return
            }
            let networkReachability = Unmanaged<SCNetworkReachability>.fromOpaque(info).takeUnretainedValue()
                as SCNetworkReachability
            let enumerator = networkReachability.blocks.objectEnumerator()
            while let object: AnyObject = enumerator?.nextObject() as AnyObject? {
                let block = unsafeBitCast(object, to: UpdateBlock.self)
                block(networkReachability)
            }
        }
        return SCNetworkReachabilitySetCallback(self, callback, &context)
            && SCNetworkReachabilityScheduleWithRunLoop(self, CFRunLoopGetCurrent(), CFRunLoopMode.defaultMode.rawValue)
    }

{'fraction_non_alphanumeric': 0.07719216417910447, 'fraction_numerical': 0.005597014925373134, 'mean_word_length': 2.294162826420891, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7252068', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1042, 'n_words': 250}