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

Reduce size of interval tree used for tagging #73703

Merged
merged 1 commit into from
May 25, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 25, 2024

Found this while doing other refactorings in this space to lower our overhead while tagging.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 25, 2024 04:29
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 25, 2024

internal partial class TagSpanIntervalTree<TTag>
{
private readonly struct TagNode(ITagSpan<TTag> tagSpan, SpanTrackingMode trackingMode)
Copy link
Member Author

@CyrusNajmabadi CyrusNajmabadi May 25, 2024

Choose a reason for hiding this comment

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

no need to store the trackingMode in the node itself. all nodes within the TagSpanIntervalTree have hte same tracking mode. So this was redundant. at that point, this entire type was redundant as it was just wrapping the ITagSpan<TTag>

public TagSpan<TTag> GetTranslatedTagSpan(ITextSnapshot textSnapshot)
=> new(GetTranslatedSpan(textSnapshot), Tag);

public SnapshotSpan GetTranslatedSpan(ITextSnapshot textSnapshot)
Copy link
Member Author

Choose a reason for hiding this comment

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

these two helpers moved to statics on the outer type.

@@ -48,7 +54,7 @@ public bool HasSpanThatContains(SnapshotPoint point)
var snapshot = point.Snapshot;
Debug.Assert(snapshot.TextBuffer == _textBuffer);

return _tree.HasIntervalThatContains(point.Position, length: 0, new IntervalIntrospector(snapshot));
return _tree.HasIntervalThatContains(point.Position, length: 0, new IntervalIntrospector(snapshot, _spanTrackingMode));
Copy link
Member Author

Choose a reason for hiding this comment

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

instead of the node needing to hold onto the tracing mode, we just pass it through with the introspector (a lightweight struct) when queryign the tree.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants