Skip to content

Commit

Permalink
prevent some boxing/unboxing, 1.0.5.27
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Nov 4, 2014
1 parent 280c18b commit 0875412
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions NBitcoin/BitcoinStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,17 @@ public void ReadWrite(ref bool data)
data = (d == 0 ? false : true);
}

public void ReadWriteStruct<T>(ref T data) where T : struct, IBitcoinSerializable
{
data.ReadWrite(this);
}

public void ReadWrite<T>(ref T data) where T : IBitcoinSerializable
{
if(data == null)
if(data == null && !Serializing)
data = Activator.CreateInstance<T>();
data.ReadWrite(this);
if(data != null)
data.ReadWrite(this);
}

public void ReadWrite<T>(ref List<T> list) where T : IBitcoinSerializable, new()
Expand Down
2 changes: 1 addition & 1 deletion NBitcoin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.26")]
[assembly: AssemblyVersion("1.0.5.27")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion NBitcoin/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public void ReadWrite(BitcoinStream stream)
stream.ReadWrite(ref nVersion);
stream.ReadWrite(ref vin);
stream.ReadWrite(ref vout);
stream.ReadWrite(ref nLockTime);
stream.ReadWriteStruct(ref nLockTime);
}

#endregion
Expand Down

0 comments on commit 0875412

Please sign in to comment.