Skip to content

empty_record clones header #493

@brentp

Description

@brentp

empty_record:

pub fn empty_record(&self) -> crate::bcf::Record {
crate::bcf::Record::new(Rc::new(self.clone()))
}
}

does a bcf_hdr_dup on the header:

impl Clone for HeaderView {
fn clone(&self) -> Self {
HeaderView {
inner: unsafe { htslib::bcf_hdr_dup(self.inner) },
}
}

Is this necessary? I think we can just clone the Rc instead?

I ask because this is showing up on a profiling run in a real application for me.

The empty_record is called for every next on a reader:

rust-htslib/src/bcf/mod.rs

Lines 802 to 808 in 8f1cdd7

fn next(&mut self) -> Option<Result<record::Record>> {
let mut record = self.reader.empty_record();
match self.reader.read(&mut record) {
Some(Err(e)) => Some(Err(e)),
Some(Ok(_)) => Some(Ok(record)),
None => None,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions