summaryrefslogtreecommitdiff
path: root/src/Store.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 14:10:14 -0300
committerGabriel Schneider <[email protected]>2026-10-24 15:50:47 -0300
commit93862a52fd695014969a272b04f442e512211a97 (patch)
tree66eb1a756f99d9e987201d010370d19c561f7f3c /src/Store.zig
parentf3405aaef8db79094b2741a9caaeaa5328ab6288 (diff)
downloadpardes-93862a52fd695014969a272b04f442e512211a97.tar.gz
pardes-93862a52fd695014969a272b04f442e512211a97.zip
Store 3/3: Recent and Panes in the guide and reference, the changelog, an unhosted core's flush returning before any host call, the design note as built with its numbers and positions
Diffstat (limited to 'src/Store.zig')
-rw-r--r--src/Store.zig21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Store.zig b/src/Store.zig
index 35033e04..e06c55e5 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -599,16 +599,10 @@ pub fn close(s: *Store, p: *Pardes, k: Kept, gainer: ?usize) void {
pub fn flush(s: *Store, p: *Pardes, wait: bool) void {
const gpa = p.recentGpa();
if (!p.recent.dirty and s.pending.items.len == 0) return;
- const path = if (comptime pardes.hosted) s.path else null;
- if (path == null or !s.loaded) {
- if (path == null) {
- for (p.recent.entries.items) |*e| e.changed = false;
- p.recent.dirty = false;
- s.pending.clearRetainingCapacity();
- for (s.closed.items) |*c| c.pending_at = null;
- }
- return;
- }
+ // No file: nothing to write it to, ever.
+ if (comptime !pardes.hosted) return s.forget(p);
+ const path: ?[]const u8 = s.path orelse return s.forget(p);
+ if (!s.loaded) return;
const io = ioOf();
var name_buf: [4096 + 16]u8 = undefined;
const lock_path = std.fmt.bufPrint(&name_buf, "{s}.lock", .{path.?}) catch return;
@@ -658,6 +652,13 @@ pub fn flush(s: *Store, p: *Pardes, wait: bool) void {
s.pending.clearRetainingCapacity();
}
+fn forget(s: *Store, p: *Pardes) void {
+ for (p.recent.entries.items) |*e| e.changed = false;
+ p.recent.dirty = false;
+ s.pending.clearRetainingCapacity();
+ for (s.closed.items) |*c| c.pending_at = null;
+}
+
fn dropPending(s: *Store, gpa: std.mem.Allocator) void {
_ = gpa;
s.pending.clearRetainingCapacity();