@@ -41,12 +41,11 @@ 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 ;
44+ protected override int ValuesPerItem => 2 ;
4645
47- protected override void Write ((double Latitude , double Longitude ) item , ref PolylineWriter writer ) {
48- writer .Write (item .Latitude , ref _latitudeState ); // field 0
49- writer .Write (item .Longitude , ref _longitudeState ); // field 1
46+ protected override void Write ((double Latitude , double Longitude ) item , ref PolylineWriter writer , PolylineValueState [] states ) {
47+ writer .Write (item .Latitude , ref states [ 0 ] ); // field 0
48+ writer .Write (item .Longitude , ref states [ 1 ]); // field 1
5049 }
5150 protected override string CreatePolyline (ReadOnlySpan <char > polyline ) => polyline .ToString ();
5251}
@@ -78,11 +77,10 @@ using PolylineAlgorithm.Abstraction;
7877using PolylineAlgorithm .Internal ;
7978
8079public sealed class MyPolylineDecoder : AbstractPolylineDecoder <string , (double Latitude , double Longitude )> {
81- private PolylineValueState _latitudeState ;
82- private PolylineValueState _longitudeState ;
80+ protected override int ValuesPerItem => 2 ;
8381
84- protected override (double Latitude , double Longitude ) Read (PolylineReader reader ) =>
85- (reader .Read (ref _latitudeState ), reader .Read (ref _longitudeState )); // field 0, field 1
82+ protected override (double Latitude , double Longitude ) Read (PolylineReader reader , PolylineValueState [] states ) =>
83+ (reader .Read (ref states [ 0 ] ), reader .Read (ref states [ 1 ] )); // field 0, field 1
8684 protected override ReadOnlyMemory <char > GetReadOnlyMemory (in string polyline ) => polyline .AsMemory ();
8785}
8886```
0 commit comments