-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
|
||
internal partial class TagSpanIntervalTree<TTag> | ||
{ | ||
private readonly struct TagNode(ITagSpan<TTag> tagSpan, SpanTrackingMode trackingMode) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found this while doing other refactorings in this space to lower our overhead while tagging.