File tree 1 file changed +7
-4
lines changed
crates/bindings-csharp/BSATN.Runtime/BSATN 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ namespace SpacetimeDB.BSATN;
2
2
3
3
using System . Text ;
4
4
5
+ internal static class StructuralReadWrite < T >
6
+ where T : IStructuralReadWrite , new ( )
7
+ {
8
+ public static readonly System . Func < T > Constructor = ( ) => new T ( ) ;
9
+ }
10
+
5
11
public interface IStructuralReadWrite
6
12
{
7
13
void ReadFields ( BinaryReader reader ) ;
@@ -11,10 +17,7 @@ public interface IStructuralReadWrite
11
17
static T Read < T > ( BinaryReader reader )
12
18
where T : IStructuralReadWrite , new ( )
13
19
{
14
- // TODO: use `RuntimeHelpers.GetUninitializedObject` as an optimisation here.
15
- // We tried but couldn't do this because BitCraft relies on being able
16
- // to add and initialize custom fields on autogenerated classes.
17
- var result = new T ( ) ;
20
+ var result = StructuralReadWrite < T > . Constructor ( ) ;
18
21
result . ReadFields ( reader ) ;
19
22
return result ;
20
23
}
You can’t perform that action at this time.
0 commit comments