Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-17431: Respect priority order when merging a footprint #451

Merged
merged 3 commits into from Apr 13, 2019

Conversation

yalsayyad
Copy link
Contributor

that overlaps previously disconnected higher priority footprints.
Include unit test that simulates this case.

Copy link
Member

@TallJimbo TallJimbo left a comment

Choose a reason for hiding this comment

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

Looks great!

One advantage of this "minimal change" version is that it's also not an ABI change, though the benefit of that mostly goes away after a new weekly comes out, so if this lands today that's not a big deal. I'm certainly happy for you to go with the bigger-change, more readable version of this if you like it better, but I think if we really wanted to make this code readable we'd need to make much more drastic changes, such as explicitly using SpanSet and PeakCatalog for the data members of FootprintMerge and only combining them into Footprints when we're done; right now it seems like we always have to work around the fact that a Footprint has both because we do different things with the spans and the peaks.

if (doMerge && first) {
// Now merge footprint including peaks into the newly-connected, higher-priority FootprintMerge
first->add(foot, _peakSchemaMapper, keyIter->second, minNewPeakDist, maxSamePeakDist);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I assume doMerge == bool(first) is guaranteed? If so, is it worth asserting on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As written no, that's not guaranteed. See new line 272. bool(first) says there was at least one overlapping FootprintMerge. doMerge is the input parameter that says "yes, merge it." Both have to be true for us to merge it. This logic I didn't change, but I also found it confusing, and why I was proposing some reordering (to move the doMerge up and out of the loop). Because what's the point of looping over existing FootprintMerges if you don't plan on merging them! Your comment demonstrated that doing that would be worthwhile. Going to put it on a different commit.

@yalsayyad
Copy link
Contributor Author

@TallJimbo I added the two additional commits I wanted to make. Will you take a look? Checked there's no behavior change and I'm rerunning Jenkins now.

// If list is empty don't check for any matches, just add all the objects
bool checkForMatches = (_mergeList.size() > 0);
// If list is empty or merging not requested, don't check for any matches, just add all the objects
bool checkForMatches = (_mergeList.size() > 0) && doMerge;
Copy link
Member

Choose a reason for hiding this comment

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

Prefer !_mergeList.empty(); this comparison will generate a signed vs. unsigned warning on some compilers.

that overlaps previously disconnected higher priority footprints.
Include unit test that simulates this case.
to allow FootprintMergeList call it directly to avoid adding footprints
twice (safe) and improve readability.
Update inline comment describe adding SpanSets rather than whole Footprints
@yalsayyad yalsayyad merged commit 8927949 into master Apr 13, 2019
@timj timj deleted the tickets/DM-17431 branch February 18, 2021 00:01
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.

None yet

2 participants