Skip to content

Conversation

cjw85
Copy link
Contributor

@cjw85 cjw85 commented Sep 30, 2025

This saves around 10-15% in programs calling the modified base APIs.

@jmarshall
Copy link
Member

Looks like a good idea.

If you lift the declarations of tmp (to the char *cp declaration) and of (as, say, failed, to the top) these can stay as one-liners, which would be nice (clearer).

@daviesrob
Copy link
Member

I'd agree that lofting particularly of could be useful. It could even be tested at the end to detect overflows, which isn't done at the moment.

It would also be a good idea to change the strtol() calls in bam_parse_basemod2(). bam_mods_at_next_pos and bam_parse_basemod2 rely somewhat on the strings being parsed in the same way, so I'd be a bit worried about subtle differences between strtol() and hts_str2uint() resulting in odd things happening if the input is not strictly spec-compliant.

sam_mods.c Outdated
if (cp != state->MM[i])
state->MMcount[i] = strtol(cp+1, NULL, 10);
else
if (cp != state->MM[i]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now there's no need to modify a bunch of surrounding lines by adding { … }.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

: 0;
if (!cp_end) {
// empty list
if (*cp == ',') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkbonfield This site made me think for a minute; the interplay of the ternary and the if(!cp_end) worried me. I believe I have the logic correct, it reads a little more direct now as a consequence.

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.

4 participants