From 8038a8836f39ab8dc65075d2a7321bd2ba5dd8ad Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 1 Jul 2015 01:37:22 -0700 Subject: [PATCH] Simplify Node constructor for trivial case. --- .../Core/Portable/Formatting/ContextIntervalTree.cs | 2 +- .../Core/Portable/Shared/Collections/IntervalTree`1.Node.cs | 6 ++++-- .../Core/Portable/Shared/Collections/IntervalTree`1.cs | 2 +- .../Portable/Shared/Collections/SimpleIntervalTree`1.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Workspaces/Core/Portable/Formatting/ContextIntervalTree.cs b/src/Workspaces/Core/Portable/Formatting/ContextIntervalTree.cs index 80d5101288d..b87a16eace8 100644 --- a/src/Workspaces/Core/Portable/Formatting/ContextIntervalTree.cs +++ b/src/Workspaces/Core/Portable/Formatting/ContextIntervalTree.cs @@ -31,7 +31,7 @@ public ContextIntervalTree(IIntervalIntrospector introspector) public void AddIntervalInPlace(T value) { - var newNode = new Node(Introspector, value); + var newNode = new Node(value); this.root = Insert(root, newNode, Introspector); } diff --git a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.Node.cs b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.Node.cs index b4c3be6731b..da7d00a6b16 100644 --- a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.Node.cs +++ b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.Node.cs @@ -18,9 +18,11 @@ protected class Node internal int Height { get; private set; } internal Node MaxEndNode { get; private set; } - internal Node(IIntervalIntrospector introspector, T interval) - : this(introspector, interval, left: null, right: null) + internal Node(T value) { + this.Value = value; + this.Height = 1; + this.MaxEndNode = this; } internal Node(IIntervalIntrospector introspector, T value, Node left, Node right) diff --git a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs index 2edaa01321a..d362e6bd0ce 100644 --- a/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs +++ b/src/Workspaces/Core/Portable/Shared/Collections/IntervalTree`1.cs @@ -31,7 +31,7 @@ public IntervalTree(IIntervalIntrospector introspector, IEnumerable values { foreach (var value in values) { - root = Insert(root, new Node(introspector, value), introspector); + root = Insert(root, new Node(value), introspector); } } diff --git a/src/Workspaces/Core/Portable/Shared/Collections/SimpleIntervalTree`1.cs b/src/Workspaces/Core/Portable/Shared/Collections/SimpleIntervalTree`1.cs index 4435343ad5c..fdb9b9d64d9 100644 --- a/src/Workspaces/Core/Portable/Shared/Collections/SimpleIntervalTree`1.cs +++ b/src/Workspaces/Core/Portable/Shared/Collections/SimpleIntervalTree`1.cs @@ -19,7 +19,7 @@ public SimpleIntervalTree(IIntervalIntrospector introspector, IEnumerable { foreach (var value in values) { - root = Insert(root, new Node(introspector, value), introspector); + root = Insert(root, new Node(value), introspector); } } } -- GitLab