atagen

malice

public
Star0
Watch0

Commit b7913beddfde

tarball

atagen <boss@atagen.co>2026-10-25 11:09 UTC

1 file changed+17-14
core: box the snapshot wire event

Snapshot made every WireEvent at least 496 bytes, and each feed delta paid for it in channel buffers and clones. The JSON is unchanged because serde flattens a boxed struct inside an internally tagged variant.
Modified file: crates/malice-core/src/feed.rs+17 additions−14 deletions
@@ -11,18 +11,7 @@ use serde::Serialize;
1111 #[derive(Debug, Clone, Serialize)]
1212 #[serde(tag = "type", rename_all = "snake_case")]
1313 pub enum WireEvent {
14- Snapshot {
15- rooms: Vec<RoomSummary>,
16- timelines: HashMap<String, Vector<TimelineItem>>,
17- pinned: HashMap<String, Vector<TimelineItem>>,
18- threads: Vec<ThreadItems>,
19- connection: String,
20- encryption: Option<EncryptionState>,
21- verification: Option<VerificationState>,
22- image_packs: ImagePacks,
23- mentions: Option<MentionsPage>,
24- recent_history: HashMap<String, RecentHistoryState>,
25- },
14+ Snapshot(Box<Snapshot>),
2615 Mentions {
2716 update: MentionsUpdate,
2817 },
@@ -81,6 +70,20 @@ pub enum WireEvent {
8170 }
8271
8372 #[derive(Debug, Clone, Serialize)]
73+pub struct Snapshot {
74+ pub rooms: Vec<RoomSummary>,
75+ pub timelines: HashMap<String, Vector<TimelineItem>>,
76+ pub pinned: HashMap<String, Vector<TimelineItem>>,
77+ pub threads: Vec<ThreadItems>,
78+ pub connection: String,
79+ pub encryption: Option<EncryptionState>,
80+ pub verification: Option<VerificationState>,
81+ pub image_packs: ImagePacks,
82+ pub mentions: Option<MentionsPage>,
83+ pub recent_history: HashMap<String, RecentHistoryState>,
84+}
85+
86+#[derive(Debug, Clone, Serialize)]
8487 pub struct ThreadItems {
8588 pub room_id: String,
8689 pub root_event_id: String,
@@ -144,7 +147,7 @@ pub fn snapshot_event(state: &State) -> WireEvent {
144147 TimelineId::Room(_) | TimelineId::Pinned(_) => None,
145148 })
146149 .collect();
147- WireEvent::Snapshot {
150+ WireEvent::Snapshot(Box::new(Snapshot {
148151 rooms: state.rooms.iter().cloned().collect(),
149152 timelines,
150153 pinned,
@@ -159,7 +162,7 @@ pub fn snapshot_event(state: &State) -> WireEvent {
159162 .iter()
160163 .map(|(room_id, status)| (room_id.as_str().to_owned(), status.clone()))
161164 .collect(),
162- }
165+ }))
163166 }
164167
165168 fn error(message: &str) -> WireEvent {