Commit cfd1ff17f1

cfd1ff17f14e9e238e308e74c5ae8d9fd7ee9169

parent: b64af33f49

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-10 05:01 UTC

Fast typing in large files; lighter agenda list and palette; run Release from Xcode

- Incremental reparse looked for settings keywords with a case-insensitive
  range(of:) over the whole file on every keystroke on a heading line
  (335 ms in a 600 KB file); now a byte search (1.6 ms).
- Agenda rows are built when the list draws them.
- The command palette works out its commands and keys once when it opens.
- The iOS scheme runs the Release build, with ORGSTAR_PERF turning on the
  main-thread watchdog; heading search is timed.

Layout: unified · split

Sources/OrgCore/Parser/Incremental.swift +1 −1
@@ -89,7 +89,7 @@ private struct ReparseContext {
8989 break
9090 }
9191 }
92 return movesBoundary && Self.settingsKeys.contains { newText.range(of: "#+\($0):", options: .caseInsensitive) != nil }
92 return movesBoundary && Self.settingsKeys.contains { newText.containsIgnoringASCIICase("#+\($0):") }
9393 }
9494
9595 // MARK: - Element
Sources/OrgstarMobile/AgendaScreen.swift +10 −3
@@ -91,7 +91,7 @@ struct AgendaScreen: View, Equatable {
9191 } else {
9292 let rows = agenda.list.filter(filter.keeps).compactMap { AgendaRow(item: $0, day: agenda.today, today: agenda.today) }
9393 if rows.isEmpty, !agenda.isComputing { Text("No entries").foregroundStyle(.secondary) }
94 ForEach(rows) { row($0, day: agenda.today) }
94 ForEach(rows) { item in Deferred { row(item, day: agenda.today) } }
9595 }
9696 if let reminderStatus {
9797 Section { } footer: { Text(reminderStatus) }
@@ -276,7 +276,7 @@ struct AgendaScreen: View, Equatable {
276276 }
277277 .buttonStyle(.plain)
278278 if overdueExpanded {
279 ForEach(group.overdue) { row($0, day: group.day) }
279 ForEach(group.overdue) { item in Deferred { row(item, day: group.day) } }
280280 }
281281 }
282282 if group.isEmpty {
@@ -286,7 +286,7 @@ struct AgendaScreen: View, Equatable {
286286 ForEach(lines(group)) { line in
287287 switch line {
288288 case .now: NowLine(time: now, color: todayColor)
289 case .row(let item): row(item, day: group.day)
289 case .row(let item): Deferred { row(item, day: group.day) }
290290 }
291291 }
292292 }
@@ -918,4 +918,11 @@ struct RefileSheet: View {
918918 }
919919 }
920920}
921/// A view built when the list draws it: a list makes every row's view up front, and a row's
922/// actions and menus cost more than the row.
923private struct Deferred<Content: View>: View {
924 @ViewBuilder let content: () -> Content
925
926 var body: some View { content() }
927}
921928#endif
Sources/OrgstarMobile/EditorScreen.swift +13 −4
@@ -436,10 +436,12 @@ struct CommandPalette: View {
436436 ("org.table.expand", "Expand Table Columns"),
437437 ]
438438
439 /// The commands that apply at the caret and their keys, worked out once when the palette
440 /// opens rather than on every keystroke in the search field.
441 @State private var applicable: [(id: String, title: String, keys: String?)]?
442
439443 var body: some View {
440 let context = editor.editContext()
441 let all = Self.viewCommands + Commands.everything.map { ($0.id, $0.title) }
442 let shown = all.filter { editor.applies($0.id, in: context) && (query.isEmpty || $0.title.localizedCaseInsensitiveContains(query)) }
444 let shown = (applicable ?? []).filter { query.isEmpty || $0.title.localizedCaseInsensitiveContains(query) }
443445 NavigationStack {
444446 List(shown, id: \.id) { command in
445447 Button {
@@ -449,7 +451,7 @@ struct CommandPalette: View {
449451 HStack {
450452 Text(command.title).foregroundStyle(.primary)
451453 Spacer()
452 if let keys = editor.keymap.keyLabels(for: command.id).first {
454 if let keys = command.keys {
453455 Text(keys).font(.caption.monospaced()).foregroundStyle(.secondary)
454456 }
455457 }
@@ -460,6 +462,13 @@ struct CommandPalette: View {
460462 .navigationBarTitleDisplayMode(.inline)
461463 .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Close") { dismiss() } } }
462464 }
465 .onAppear {
466 guard applicable == nil else { return }
467 let context = editor.editContext()
468 applicable = (Self.viewCommands + Commands.everything.map { ($0.id, $0.title) })
469 .filter { editor.applies($0.id, in: context) }
470 .map { ($0.id, $0.title, editor.keymap.keyLabels(for: $0.id).first) }
471 }
463472 }
464473}
465474#endif
Sources/OrgstarMobile/OrgstarMobileApp.swift +3
@@ -12,8 +12,11 @@ struct OrgstarMobileApp: App {
1212 @State private var model = MobileModel.shared
1313
1414 init() {
15 // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF.
1516 #if DEBUG
1617 Perf.watchMainThread()
18 #else
19 if ProcessInfo.processInfo.environment["ORGSTAR_PERF"] != nil { Perf.watchMainThread() }
1720 #endif
1821 LiveClock.install()
1922 }
Sources/OrgstarMobile/SearchScreen.swift +1 −1
@@ -23,7 +23,7 @@ struct SearchScreen: View {
2323 }
2424 }
2525 }
26 let headings = workspace.search(trimmed, overlay: workspace.overlay(session.openDocuments))
26 let headings = Perf.measure("search.headings") { workspace.search(trimmed, overlay: workspace.overlay(session.openDocuments)) }
2727 Section("Headings") {
2828 if headings.isEmpty { Text("No headings match").foregroundStyle(.secondary) }
2929 ForEach(headings, id: \.self) { location in
ios/Orgstar.xcodeproj/xcshareddata/xcschemes/Orgstar iOS.xcscheme +8 −1
@@ -29,7 +29,7 @@
2929 shouldUseLaunchSchemeArgsEnv = "YES">
3030 </TestAction>
3131 <LaunchAction
32 buildConfiguration = "Debug"
32 buildConfiguration = "Release"
3333 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3434 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3535 launchStyle = "0"
@@ -48,6 +48,13 @@
4848 ReferencedContainer = "container:Orgstar.xcodeproj">
4949 </BuildableReference>
5050 </BuildableProductRunnable>
51 <EnvironmentVariables>
52 <EnvironmentVariable
53 key = "ORGSTAR_PERF"
54 value = "1"
55 isEnabled = "YES">
56 </EnvironmentVariable>
57 </EnvironmentVariables>
5158 </LaunchAction>
5259 <ProfileAction
5360 buildConfiguration = "Release"