Commit e9b4489
refactor(bam): address review feedback and review-pass findings
Incorporates Nils's review thread (accepted items) plus findings from a
/simplify + code-review pass.
From Nils:
- Derive Clone on Template
- Add EmptyTemplate error; new(vec![]) now errors
- Store qnames as Vec<u8> in TemplateError (preserves non-UTF-8 bytes)
- Add all_r1s(), all_r2s(), len(), is_empty()
- Reorder all_recs() to match fgbio Scala: r1, r2, r1_supp, r2_supp,
r1_sec, r2_sec
- Add new_unchecked() for hot paths where invariants are guaranteed
- Doctests are runnable (no more `ignore`)
From the review pass:
- Drop per-record Vec<u8> allocation in new() hot path; hoist the
String allocation out of the success path
- Share a private push() helper between new() and new_unchecked() to
remove duplicated classification dispatch
- Flatten the 3-level if-cascade into a single match on (Bucket, is_r1)
- Short-circuit name() with an or_else chain
- Document that direct field mutation can void invariants
- Add tests for: R1+R2 supplementaries with both primaries,
LAST_IN_PAIR without PAIRED, non-UTF-8 qnames in error round-trip,
len/is_empty/all_r1s/all_r2s/Clone
Open: supplementaries vs supplementals naming pending Nils's reply;
TryFrom<IntoIterator> deferred (new() already takes IntoIterator).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5d1d289 commit e9b4489
1 file changed
Lines changed: 410 additions & 136 deletions
0 commit comments