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

chore: Simplify location uniquing #63263

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Conversation

varungandhi-src
Copy link
Contributor

The code earlier constructing the locations attaches the same
uploadID and path to all of them, so trying to use those while
uniquing is wasteful. Let's stop doing that.

Test plan

Covered by existing tests

Changelog

@cla-bot cla-bot bot added the cla-signed label Jun 14, 2024
@github-actions github-actions bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Jun 14, 2024
@@ -354,22 +354,12 @@ func (s *store) extractLocationsFromPosition(
}
}

return deduplicateLocations(locations), collections.DeduplicateBy(symbols, func(s string) string { return s }), nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this, there is a call

locations = append(locations, convertSCIPRangesToLocations(ranges, locationKey.UploadID, locationKey.Path)...)

So all locations have the same UploadID and Path.

@varungandhi-src varungandhi-src enabled auto-merge (squash) June 14, 2024 07:29
Copy link
Contributor

@kritzcreek kritzcreek left a comment

Choose a reason for hiding this comment

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

LGTM, some nits

@@ -354,22 +354,12 @@ func (s *store) extractLocationsFromPosition(
}
}

return deduplicateLocations(locations), collections.DeduplicateBy(symbols, func(s string) string { return s }), nil
// We only need to unique by the range, since all location objects share the same path and uploadID.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// We only need to unique by the range, since all location objects share the same path and uploadID.
// We only need to deduplicate by range, since all location objects share the same path and uploadID.

seen.Add(x)
filtered = append(filtered, x)
}
return filtered
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably call slices.Clip on the result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For defensiveness in the case of aliasing? Clipping the result will trigger a copy on future appends.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that was my thinking. Honestly slices terrify me...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to be actually defensive in the case of aliasing, you'd have to construct a copy, and we don't want to do that here. I don't think it's worth taking half-measures like this.

@kritzcreek kritzcreek self-requested a review June 14, 2024 07:35
Copy link
Contributor

@kritzcreek kritzcreek left a comment

Choose a reason for hiding this comment

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

some nits (sorry for the noise, didn't see the automerge)

@varungandhi-src varungandhi-src merged commit e0fcb49 into main Jun 14, 2024
13 checks passed
@varungandhi-src varungandhi-src deleted the vg/remove-redundant-uniquing branch June 14, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants