@@ -41,9 +41,12 @@ using PolylineAlgorithm.Abstraction;
4141using PolylineAlgorithm .Internal ;
4242
4343public sealed class MyPolylineEncoder : AbstractPolylineEncoder <(double Latitude , double Longitude ), string > {
44+ private PolylineValueState _latitudeState ;
45+ private PolylineValueState _longitudeState ;
46+
4447 protected override void Write ((double Latitude , double Longitude ) item , ref PolylineWriter writer ) {
45- writer .Write (item .Latitude ); // field 0
46- writer .Write (item .Longitude ); // field 1
48+ writer .Write (item .Latitude , ref _latitudeState ); // field 0
49+ writer .Write (item .Longitude , ref _longitudeState ); // field 1
4750 }
4851 protected override string CreatePolyline (ReadOnlySpan <char > polyline ) => polyline .ToString ();
4952}
@@ -75,8 +78,11 @@ using PolylineAlgorithm.Abstraction;
7578using PolylineAlgorithm .Internal ;
7679
7780public sealed class MyPolylineDecoder : AbstractPolylineDecoder <string , (double Latitude , double Longitude )> {
81+ private PolylineValueState _latitudeState ;
82+ private PolylineValueState _longitudeState ;
83+
7884 protected override (double Latitude , double Longitude ) Read (PolylineReader reader ) =>
79- (reader .Read (), reader .Read ()); // field 0, field 1
85+ (reader .Read (ref _latitudeState ), reader .Read (ref _longitudeState )); // field 0, field 1
8086 protected override ReadOnlyMemory <char > GetReadOnlyMemory (in string polyline ) => polyline .AsMemory ();
8187}
8288```
0 commit comments