Skip to content

Commit 9ae0f72

Browse files
ewelsclaude
andcommitted
chore(simplify): accept IntoIterator in build_transcriptome_records_pe
Caller had a `Vec<&Box<PairedAlignment>>` and was building a throwaway `Vec<&PairedAlignment>` to match the function's `&[&PairedAlignment]` signature. Change the signature to `IntoIterator<Item = &PairedAlignment>` and call `.iter().map(|b| b.as_ref())` at the call-site, eliminating the intermediate Vec allocation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b6c5449 commit 9ae0f72

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ fn build_transcriptome_records_se(
561561
/// SAM record per projected pair per mate (2 records per projected hit, in
562562
/// mate1-then-mate2 order).
563563
#[allow(clippy::too_many_arguments)]
564-
fn build_transcriptome_records_pe(
565-
both_mapped: &[&crate::align::read_align::PairedAlignment],
564+
fn build_transcriptome_records_pe<'a, I>(
565+
both_mapped: I,
566566
read_name: &str,
567567
m1_seq: &[u8],
568568
m1_qual: &[u8],
@@ -572,12 +572,15 @@ fn build_transcriptome_records_pe(
572572
tr_idx: &crate::quant::transcriptome::TranscriptomeIndex,
573573
params: &Parameters,
574574
n_for_mapq: usize,
575-
) -> Result<Vec<noodles::sam::alignment::record_buf::RecordBuf>, error::Error> {
575+
) -> Result<Vec<noodles::sam::alignment::record_buf::RecordBuf>, error::Error>
576+
where
577+
I: IntoIterator<Item = &'a crate::align::read_align::PairedAlignment>,
578+
{
576579
use crate::io::sam::SamWriter;
577580
use crate::quant::transcriptome::filter_and_project;
578581
use std::collections::HashMap;
579582

580-
if both_mapped.is_empty() || tr_idx.n_transcripts() == 0 {
583+
if tr_idx.n_transcripts() == 0 {
581584
return Ok(Vec::new());
582585
}
583586

@@ -1370,10 +1373,8 @@ fn align_reads_paired_end<W: AlignmentWriter>(
13701373
// Transcriptome SAM projection (both-mapped pairs only)
13711374
let transcriptome_records: Vec<noodles::sam::alignment::record_buf::RecordBuf> =
13721375
if let Some(ref tidx) = tr_local {
1373-
let bm_deref: Vec<&crate::align::read_align::PairedAlignment> =
1374-
both_mapped.iter().map(|b| b.as_ref()).collect();
13751376
build_transcriptome_records_pe(
1376-
&bm_deref,
1377+
both_mapped.iter().map(|b| b.as_ref()),
13771378
&paired_read.name,
13781379
&m1_seq,
13791380
&m1_qual,

0 commit comments

Comments
 (0)