mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-28 05:04:15 -05:00
make with_recording_playback less monomorphized
This is a minor code size reduction - instead of being monomorphized into four variants (according to "cargo llvm-lines"), it's now monomorphized into two. The stripped release binary on macOS is about 8kB smaller (0.15%). Not a huge improvement but better than nothing. Benchmarks seem unchanged (though they have a lot of variance).
This commit is contained in:
@@ -382,8 +382,8 @@ impl Segment {
|
||||
self.index_once.call_once(|| {
|
||||
let index = unsafe { &mut *self.index.get() };
|
||||
*index = db.lock()
|
||||
.with_recording_playback(self.s.id, |playback| self.build_index(playback))
|
||||
.map_err(|e| { error!("Unable to build index for segment: {:?}", e); });
|
||||
.with_recording_playback(self.s.id, &mut |playback| self.build_index(playback))
|
||||
.map_err(|e| { error!("Unable to build index for segment: {:?}", e); });
|
||||
});
|
||||
let index: &'a _ = unsafe { &*self.index.get() };
|
||||
match *index {
|
||||
@@ -627,7 +627,7 @@ impl Slice {
|
||||
}
|
||||
let truns =
|
||||
mp4.0.db.lock()
|
||||
.with_recording_playback(s.s.id, |playback| s.truns(playback, pos, len))?;
|
||||
.with_recording_playback(s.s.id, &mut |playback| s.truns(playback, pos, len))?;
|
||||
let truns = ARefs::new(truns);
|
||||
Ok(truns.map(|t| &t[r.start as usize .. r.end as usize]))
|
||||
}
|
||||
@@ -2275,7 +2275,7 @@ mod bench {
|
||||
let rel_range_90k = 0 .. row.duration_90k;
|
||||
super::Segment::new(&db, &row, rel_range_90k, 1).unwrap()
|
||||
};
|
||||
db.with_recording_playback(segment.s.id, |playback| {
|
||||
db.with_recording_playback(segment.s.id, &mut |playback| {
|
||||
let v = segment.build_index(playback).unwrap(); // warm.
|
||||
b.bytes = v.len() as u64; // define the benchmark performance in terms of output bytes.
|
||||
b.iter(|| segment.build_index(playback).unwrap());
|
||||
|
||||
@@ -302,7 +302,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn get_frames(db: &db::LockedDatabase, id: CompositeId) -> Vec<Frame> {
|
||||
db.with_recording_playback(id, |rec| {
|
||||
db.with_recording_playback(id, &mut |rec| {
|
||||
let mut it = recording::SampleIndexIterator::new();
|
||||
let mut frames = Vec::new();
|
||||
while it.next(&rec.video_index).unwrap() {
|
||||
|
||||
Reference in New Issue
Block a user