authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 14:22:12-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 15:13:32-07:00
log755934ca6dd1bd690b5bbcceb676443e14479133
tree3983a0e8336fc7d1bf6486c92c4f4311bbb0d045
parent7865e773c24cb9a24fbe145bf63fc3fee561fc49
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

chore: Library::open_by takes its notifier boxed, compiling once instead of once per caller

Its instantiations shrink from 392 KB to 128 KB. Release executables after the debug split: Linux x86_64 48.78 to 48.45 MB (-0.33), macOS aarch64 34.85 to 34.49 MB (-0.36). Assisted-by: claude-opus-5.5

1 files changed, 5 insertions(+), 4 deletions(-)

crates/snowbound/src/library.rs+5-4
......@@ -796,14 +796,15 @@ impl Library {
796796 ) -> Result<Section, Box<dyn Error>> {
797797 // The background may hold the replica for a step, which takes a network round trip,
798798 // or be making it as an offline copy.
799 self.open_by(path, notify, Instant::now() + TIMEOUT * 3)
799 self.open_by(path, Box::new(notify), Instant::now() + TIMEOUT * 3)
800800 }
801801
802 /// `open`, waiting until `deadline` for whatever holds the section's replica.
802 /// `open`, waiting until `deadline` for whatever holds the section's replica. `notify` is
803 /// boxed to compile this once rather than once per caller's closure.
803804 fn open_by(
804805 &self,
805806 path: &str,
806 notify: impl Fn() + Send + 'static,
807 notify: Box<dyn Fn() + Send>,
807808 deadline: Instant,
808809 ) -> Result<Section, Box<dyn Error>> {
809810 let notify = Arc::new(Mutex::new(notify));
......@@ -901,7 +902,7 @@ impl Library {
901902 path: &str,
902903 notify: impl Fn() + Send + 'static,
903904 ) -> Result<Arc<notebook::Replica>, Box<dyn Error>> {
904 let section = self.open_by(path, notify, Instant::now())?;
905 let section = self.open_by(path, Box::new(notify), Instant::now())?;
905906 let replica = Arc::clone(section.replica());
906907 self.keep(path, section);
907908 Ok(replica)