-
NSLayoutManager.setTemporaryAttributes(:forCharacterRange:)
is far faster thanNSTextStorage.setAttributes(:range:)
. On My iMac, former took about 2 seconds, and latter took about 17 seconds in optimised build of test suit. -
Anyway, modifying
NSTextStorage
also took 2 seconds when wrapped bybeginEditing
/endEditing
pair. So this performance drop is mainly due to inefficient layout refresh. You will get same performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd TestApp1 | |
DEST="platform=iOS Simulator,name=iPhone 8,OS=13.6" | |
SIGNFLAGS="CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO" | |
xcodebuild clean build test -scheme TestApp1 -sdk iphonesimulator -destination "$DEST" $SIGNFLAGS | |
~ | |
~ | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
final class Task<I,O> { | |
let control = PassthroughSubject<Int,Error>() | |
let report = PassthroughSubject<Int,Error>() | |
init() { | |
let i = Channel(control) | |
let o = Channel(report) | |
DispatchQueue.global().async { [i,o] in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// SwiftUIWithNSWindowWithoutTitlebar1 | |
// | |
// Created by Henry Hathaway on 1/9/20. | |
// Copyright © 2020 Eonil. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension RelPath: Comparable { | |
/// Sorts by lexicographical topological order. | |
public static func < (_ a:RelPath, _ b:RelPath) -> Bool { | |
let c = Swift.min(a.count, b.count) | |
for i in 0..<c { | |
if a[i] < b[i] { return true } | |
if a[i] > b[i] { return false } | |
} | |
return a.count < b.count | |
} |
NewerOlder