Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

chore: Simplify location uniquing#63263

Merged
varungandhi-src merged 2 commits into
mainfrom
vg/remove-redundant-uniquing
Jun 14, 2024
Merged

chore: Simplify location uniquing#63263
varungandhi-src merged 2 commits into
mainfrom
vg/remove-redundant-uniquing

Conversation

@varungandhi-src

Copy link
Copy Markdown
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
}
}

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

Copy link
Copy Markdown
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

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, some nits

}

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
Copy Markdown
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

@kritzcreek kritzcreek Jun 14, 2024

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Contributor

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
@varungandhi-src varungandhi-src deleted the vg/remove-redundant-uniquing branch June 14, 2024 08:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

2 participants