Skip to content

#52 Improve efficiency seqmetrics instability index - #55

Merged
LCrossman merged 3 commits into
LCrossman:mainfrom
ChinmayMoghe:main
Oct 15, 2026
Merged

LCrossman merged 3 commits into
LCrossman:mainfrom
ChinmayMoghe:main

Conversation

@ChinmayMoghe

Copy link
Copy Markdown
Contributor

Improve efficiency seqmetrics instability index

Context

Issue #52

Under instability_index fn there is a String allocation to look up the weights,

for window in chars.windows(2) {
        let pair = format!("{}{}", window[0], window[1]);
        if let Some(val) = weights.get(&pair) {
            total += val;
        }

This could be avoided by not constructing a string as a key for weight lookup and rely on tuple of chars

What changed ?

load_instability -> Replaced key from String to (char, char), along with validation errors since if the key is invalid it's better to fail than have invalid / incomplete hash map for lookups

instability_index -> Removed format!() and replaced with (window[0], window[1]) for lookup

Tests

  • Cargo test

@LCrossman

Copy link
Copy Markdown
Owner

this PR refactors for better error handling and improves efficiency with changing String allocation to a tuple. All tests pass and produce the expected output locally

@LCrossman
LCrossman merged commit 0222bf4 into LCrossman:main Oct 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants