@@ -27,7 +27,7 @@ public class Asn1Reader {
2727 readonly Dictionary < Int64 , AsnInternalMap > _offsetMap = [ ] ;
2828 AsnInternalMap currentPosition ;
2929 Int32 childCount ;
30-
30+
3131 /// <summary>
3232 /// Initializes a new instance of the <strong>ASN1</strong> class from an existing
3333 /// <strong>ASN1</strong> object.
@@ -59,6 +59,12 @@ public Asn1Reader(ReadOnlyMemory<Byte> rawData) : this(rawData, 0) { }
5959 _offsetMap . Add ( 0 , currentPosition ) ;
6060 decode ( rawData , offset , skipCopy ) ;
6161 }
62+ // this constructor is used for clone purposes only.
63+ Asn1Reader ( ReadOnlyMemory < Byte > rawData , AsnInternalMap position , Int32 childCount ) {
64+ _rawData = rawData ;
65+ currentPosition = new AsnInternalMap ( position . LevelStart , position . LevelEnd ) ;
66+ this . childCount = childCount ;
67+ }
6268
6369 /// <summary>
6470 /// Gets current position in the byte array stored in current data source.
@@ -593,9 +599,7 @@ public Asn1Reader GetReader() {
593599 /// </summary>
594600 /// <returns>A cloned instance of <see cref="Asn1Reader"/>.</returns>
595601 public Asn1Reader Clone ( ) {
596- var reader = new Asn1Reader ( GetRawDataAsMemory ( ) , 0 , true ) {
597- currentPosition = new AsnInternalMap ( currentPosition . LevelStart , currentPosition . LevelEnd ) ,
598- childCount = childCount ,
602+ var reader = new Asn1Reader ( _rawData , currentPosition , childCount ) {
599603 Tag = Tag ,
600604 TagName = TagName ,
601605 TagLength = TagLength ,
0 commit comments