Skip to content

Commit 2592259

Browse files
jnyrupmatt-lethargic
authored andcommitted
Optimizations (#138)
* Use TryGetValue over ContainsKey+Indexer * Use generic comparison to avoid boxing
1 parent 957c7f7 commit 2592259

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/GeoJSON.Net/CoordinateReferenceSystem/CRSBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public bool Equals(CRSBase left, CRSBase right)
7474

7575
foreach (var item in left.Properties)
7676
{
77-
if (!right.Properties.ContainsKey(item.Key))
77+
if (!right.Properties.TryGetValue(item.Key, out object rightValue))
7878
{
7979
return false;
8080
}
81-
if (!object.Equals(item.Value, right.Properties[item.Key]))
81+
if (!object.Equals(item.Value, rightValue))
8282
{
8383
return false;
8484
}

src/GeoJSON.Net/Feature/Feature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public bool Equals(Feature<TGeometry> other)
190190
return false;
191191
}
192192

193-
return Geometry.Equals(other.Geometry);
193+
return EqualityComparer<TGeometry>.Default.Equals(Geometry, other.Geometry);
194194
}
195195

196196
public override bool Equals(object obj)
@@ -215,4 +215,4 @@ public override int GetHashCode()
215215
return !(left?.Equals(right) ?? ReferenceEquals(null, right));
216216
}
217217
}
218-
}
218+
}

src/GeoJSON.Net/Geometry/LineString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool IsClosed()
6868

6969
return firstCoordinate.Longitude.Equals(lastCoordinate.Longitude)
7070
&& firstCoordinate.Latitude.Equals(lastCoordinate.Latitude)
71-
&& firstCoordinate.Altitude.Equals(lastCoordinate.Altitude);
71+
&& Nullable.Equals(firstCoordinate.Altitude, lastCoordinate.Altitude);
7272
}
7373

7474
/// <summary>

0 commit comments

Comments
 (0)