@@ -94,87 +94,29 @@ public Polyline Append(ReadOnlyMemory<char> value) {
94
94
return this ;
95
95
}
96
96
97
- Memory < char > temp = new char [ Length + value . Length ] ;
97
+ long position = 0 ;
98
+ var enumerator = Value . GetEnumerator ( ) ;
99
+ var right = new SequenceReader < byte > ( other . Value ) ;
98
100
99
- Value . CopyTo ( temp ) ;
100
- value . CopyTo ( temp [ Value . Length ..] ) ;
101
-
101
+ while ( true ) {
102
+ if ( ! enumerator . MoveNext ( ) ) {
103
+ break ;
104
+ }
102
105
103
- return Polyline . FromMemory ( temp ) ;
104
- }
105
-
106
- //private PolylineSegment GetSegments(out PolylineSegment initial) {
107
- // initial = new PolylineSegment(Value.First);
108
-
109
- // if (Value.IsSingleSegment) {
110
- // return initial;
111
- // }
112
-
113
- // PolylineSegment? current = null;
114
-
115
- // foreach (var segment in Value) {
116
- // if (current is null) {
117
- // current = initial;
118
- // } else {
119
- // current = current.Append(segment);
120
- // }
121
- // }
122
-
123
- // // Current will never be null in case we return from the method early using Value.IsSingleSegment property check
124
- // return current!;
125
- //}
126
-
127
- #region Overrides
128
-
129
- /// <inheritdoc />
130
- [ ExcludeFromCodeCoverage ]
131
- public override bool Equals ( object ? obj ) => obj is Polyline polyline && Equals ( polyline ) ;
132
-
133
- /// <inheritdoc />
134
- [ ExcludeFromCodeCoverage ]
135
- public override int GetHashCode ( ) => HashCode . Combine ( Value ) ;
136
-
137
- #endregion
138
-
139
- #region IEquatable<Polyline> implementation
106
+ if ( enumerator . Current . IsEmpty ) {
107
+ continue ;
108
+ }
140
109
141
- /// <inheritdoc />
142
- public bool Equals ( Polyline other ) {
143
- if ( IsEmpty && other . IsEmpty ) {
144
- return true ;
145
- }
110
+ if ( ! right . IsNext ( enumerator . Current . Span , true ) ) {
111
+ break ;
112
+ }
146
113
147
- if ( Length != other . Length ) {
148
- return false ;
114
+ position += enumerator . Current . Length ;
149
115
}
150
116
151
- return Value . Span . SequenceEqual ( other . Value . Span ) ;
117
+ return position == right . Length ;
152
118
}
153
119
154
- #endregion
155
-
156
- #region Equality operators
157
-
158
- /// <summary>
159
- /// Indicates whether the values of two specified <see cref="Polyline" /> objects are equal.
160
- /// </summary>
161
- /// <param name="left">The first object to compare.</param>
162
- /// <param name="right">The second object to compare.</param>
163
- /// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are equal; otherwise, <see langword="false"/>.</returns>
164
- [ ExcludeFromCodeCoverage ]
165
- public static bool operator == ( Polyline left , Polyline right ) => left . Equals ( right ) ;
166
-
167
- /// <summary>
168
- /// Indicates whether the values of two specified <see cref="Polyline" /> objects are not equal.
169
- /// </summary>
170
- /// <param name="left">The first object to compare.</param>
171
- /// <param name="right">The second object to compare.</param>
172
- /// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are not equal; otherwise, <see langword="false"/>.</returns>
173
- [ ExcludeFromCodeCoverage ]
174
- public static bool operator != ( Polyline left , Polyline right ) => ! ( left == right ) ;
175
-
176
- #endregion
177
-
178
120
#region Factory methods
179
121
180
122
/// <summary>
0 commit comments