Skip to content

Commit e62f774

Browse files
committed
optimized Polyline struct
1 parent c8852a7 commit e62f774

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/PolylineAlgorithm/Polyline.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,7 @@ public override string ToString() {
9393
var sb = Value.Length <= int.MaxValue ? new StringBuilder((int)Value.Length) : new StringBuilder();
9494
var enumerator = Value.GetEnumerator();
9595

96-
while (true) {
97-
if (!enumerator.MoveNext()) {
98-
break;
99-
}
100-
101-
if (enumerator.Current.IsEmpty) {
102-
continue;
103-
}
104-
96+
while (enumerator.MoveNext() && !enumerator.Current.IsEmpty) {
10597
sb.Append(enumerator.Current.Span);
10698
}
10799

@@ -118,6 +110,10 @@ public bool Equals(Polyline other) {
118110
return false;
119111
}
120112

113+
if (Value.IsSingleSegment && other.Value.IsSingleSegment) {
114+
return Value.FirstSpan.SequenceEqual(other.Value.FirstSpan);
115+
}
116+
121117
var enumerator = GetEnumerator();
122118
var reader = new SequenceReader<char>(other.Value);
123119

0 commit comments

Comments
 (0)