Skip to content

Commit 7d91acc

Browse files
committed
Decouple STuple<..> from TuPack by removing ITupleSerializable support
1 parent 57e58e8 commit 7d91acc

File tree

11 files changed

+16
-135
lines changed

11 files changed

+16
-135
lines changed

FoundationDB.Client/Shared/Tuples/JoinedTuple.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Doxense.Collections.Tuples
3939

4040
/// <summary>Tuple that represents the concatenation of two tuples</summary>
4141
[DebuggerDisplay("{ToString(),nq}")]
42-
public sealed class JoinedTuple : ITuple, ITupleSerializable
42+
public sealed class JoinedTuple : ITuple
4343
{
4444
// Uses cases: joining a 'subspace' tuple (customerId, 'Users', ) with a 'key' tuple (userId, 'Contacts', 123, )
4545

@@ -66,18 +66,6 @@ public JoinedTuple(ITuple head, ITuple tail)
6666
m_count = m_split + tail.Count;
6767
}
6868

69-
70-
void ITupleSerializable.PackTo(ref TupleWriter writer)
71-
{
72-
PackTo(ref writer);
73-
}
74-
75-
internal void PackTo(ref TupleWriter writer)
76-
{
77-
TupleEncoder.WriteTo(ref writer, this.Head);
78-
TupleEncoder.WriteTo(ref writer, this.Tail);
79-
}
80-
8169
public override string ToString()
8270
{
8371
return STuple.Formatter.ToString(this);

FoundationDB.Client/Shared/Tuples/LinkedTuple.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Doxense.Collections.Tuples
3838
/// <summary>Tuple that adds a value at the end of an already existing tuple</summary>
3939
/// <typeparam name="T">Type of the last value of the tuple</typeparam>
4040
[DebuggerDisplay("{ToString(),nq}")]
41-
public sealed class LinkedTuple<T> : ITuple, ITupleSerializable
41+
public sealed class LinkedTuple<T> : ITuple
4242
{
4343
//TODO: consider changing this to a struct ?
4444

@@ -64,19 +64,6 @@ public LinkedTuple([NotNull] ITuple head, T tail)
6464
this.Depth = head.Count;
6565
}
6666

67-
/// <summary>Pack this tuple into a buffer</summary>
68-
void ITupleSerializable.PackTo(ref TupleWriter writer)
69-
{
70-
PackTo(ref writer);
71-
}
72-
73-
/// <summary>Pack this tuple into a buffer</summary>
74-
internal void PackTo(ref TupleWriter writer)
75-
{
76-
TupleEncoder.WriteTo(ref writer, this.Head);
77-
TuplePacker<T>.SerializeTo(ref writer, this.Tail);
78-
}
79-
8067
/// <summary>Returns the number of elements in this tuple</summary>
8168
public int Count => this.Depth + 1;
8269

FoundationDB.Client/Shared/Tuples/ListTuple.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Doxense.Collections.Tuples
3838
using JetBrains.Annotations;
3939

4040
/// <summary>Tuple that can hold any number of untyped items</summary>
41-
public sealed class ListTuple : ITuple, ITupleSerializable
41+
public sealed class ListTuple : ITuple
4242
{
4343
// We could use a ListTuple<T> for tuples where all items are of type T, and ListTuple could derive from ListTuple<object>.
4444
// => this could speed up a bit the use case of STuple.FromArray<T> or STuple.FromSequence<T>
@@ -225,24 +225,6 @@ private static IEnumerator<object> Enumerate(object[] items, int offset, int cou
225225
}
226226
}
227227

228-
229-
void ITupleSerializable.PackTo(ref TupleWriter writer)
230-
{
231-
PackTo(ref writer);
232-
}
233-
234-
internal void PackTo(ref TupleWriter writer)
235-
{
236-
//REVIEW: this is VERY slow!
237-
int count = m_count;
238-
var items = m_items;
239-
int offset = m_offset;
240-
for (int i = 0; i < count; i++)
241-
{
242-
TuplePackers.SerializeObjectTo(ref writer, items[i + offset]);
243-
}
244-
}
245-
246228
public override string ToString()
247229
{
248230
return STuple.Formatter.ToString(m_items, m_offset, m_count);

FoundationDB.Client/Shared/Tuples/STuple.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Doxense.Collections.Tuples
4242

4343
/// <summary>Factory class for Tuples</summary>
4444
[PublicAPI]
45-
public readonly struct STuple : ITuple, ITupleSerializable
45+
public readonly struct STuple : ITuple
4646
{
4747
//note: We cannot use 'Tuple' because it's already used by the BCL in the System namespace, and we cannot use 'Tuples' either because it is part of the namespace...
4848

@@ -74,16 +74,6 @@ public ITuple Concat(ITuple tuple)
7474
return tuple;
7575
}
7676

77-
void ITupleSerializable.PackTo(ref TupleWriter writer)
78-
{
79-
PackTo(ref writer);
80-
}
81-
82-
internal void PackTo(ref TupleWriter writer)
83-
{
84-
//NO-OP
85-
}
86-
8777
public void CopyTo(object[] array, int offset)
8878
{
8979
//NO-OP

FoundationDB.Client/Shared/Tuples/STuple`1.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Doxense.Collections.Tuples
4242
/// <summary>Tuple that holds only one item</summary>
4343
/// <typeparam name="T1">Type of the item</typeparam>
4444
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
45-
public readonly struct STuple<T1> : ITuple, ITupleSerializable, IEquatable<STuple<T1>>, IEquatable<ValueTuple<T1>>
45+
public readonly struct STuple<T1> : ITuple, IEquatable<STuple<T1>>, IEquatable<ValueTuple<T1>>
4646
{
4747
// This is mostly used by code that create a lot of temporary singleton, to reduce the pressure on the Garbage Collector by allocating them on the stack.
4848
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -82,17 +82,6 @@ public TItem Get<TItem>(int index)
8282
return TypeConverters.Convert<T1, TItem>(this.Item1);
8383
}
8484

85-
void ITupleSerializable.PackTo(ref TupleWriter writer)
86-
{
87-
PackTo(ref writer);
88-
}
89-
90-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
91-
internal void PackTo(ref TupleWriter writer)
92-
{
93-
TupleSerializer<T1>.Default.PackTo(ref writer, in this);
94-
}
95-
9685
ITuple ITuple.Append<T2>(T2 value)
9786
{
9887
return new STuple<T1, T2>(this.Item1, value);

FoundationDB.Client/Shared/Tuples/STuple`2.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace Doxense.Collections.Tuples
4343
/// <typeparam name="T1">Type of the first item</typeparam>
4444
/// <typeparam name="T2">Type of the second item</typeparam>
4545
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
46-
public readonly struct STuple<T1, T2> : ITuple, ITupleSerializable, IEquatable<STuple<T1, T2>>, IEquatable<(T1, T2)>
46+
public readonly struct STuple<T1, T2> : ITuple, IEquatable<STuple<T1, T2>>, IEquatable<(T1, T2)>
4747
{
4848
// This is mostly used by code that create a lot of temporary pair, to reduce the pressure on the Garbage Collector by allocating them on the stack.
4949
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -111,17 +111,6 @@ public STuple<T2> Tail
111111
get { return new STuple<T2>(this.Item2); }
112112
}
113113

114-
void ITupleSerializable.PackTo(ref TupleWriter writer)
115-
{
116-
PackTo(ref writer);
117-
}
118-
119-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
120-
internal void PackTo(ref TupleWriter writer)
121-
{
122-
TupleSerializer<T1, T2>.Default.PackTo(ref writer, in this);
123-
}
124-
125114
ITuple ITuple.Append<T3>(T3 value)
126115
{
127116
return new STuple<T1, T2, T3>(this.Item1, this.Item2, value);

FoundationDB.Client/Shared/Tuples/STuple`3.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace Doxense.Collections.Tuples
4444
/// <typeparam name="T2">Type of the second item</typeparam>
4545
/// <typeparam name="T3">Type of the third item</typeparam>
4646
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
47-
public readonly struct STuple<T1, T2, T3> : ITuple, ITupleSerializable, IEquatable<STuple<T1, T2, T3>>, IEquatable<(T1, T2, T3)>
47+
public readonly struct STuple<T1, T2, T3> : ITuple, IEquatable<STuple<T1, T2, T3>>, IEquatable<(T1, T2, T3)>
4848
{
4949
// This is mostly used by code that create a lot of temporary triplet, to reduce the pressure on the Garbage Collector by allocating them on the stack.
5050
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -117,17 +117,6 @@ public STuple<T2, T3> Tail
117117
get { return new STuple<T2, T3>(this.Item2, this.Item3); }
118118
}
119119

120-
void ITupleSerializable.PackTo(ref TupleWriter writer)
121-
{
122-
PackTo(ref writer);
123-
}
124-
125-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
126-
internal void PackTo(ref TupleWriter writer)
127-
{
128-
TupleSerializer<T1, T2, T3>.Default.PackTo(ref writer, in this);
129-
}
130-
131120
ITuple ITuple.Append<T4>(T4 value)
132121
{
133122
// here, the caller doesn't care about the exact tuple type, so we simply return a boxed List Tuple.

FoundationDB.Client/Shared/Tuples/STuple`4.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Doxense.Collections.Tuples
4545
/// <typeparam name="T3">Type of the third item</typeparam>
4646
/// <typeparam name="T4">Type of the fourth item</typeparam>
4747
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
48-
public readonly struct STuple<T1, T2, T3, T4> : ITuple, ITupleSerializable, IEquatable<STuple<T1, T2, T3, T4>>, IEquatable<(T1, T2, T3, T4)>
48+
public readonly struct STuple<T1, T2, T3, T4> : ITuple, IEquatable<STuple<T1, T2, T3, T4>>, IEquatable<(T1, T2, T3, T4)>
4949
{
5050
// This is mostly used by code that create a lot of temporary quartets, to reduce the pressure on the Garbage Collector by allocating them on the stack.
5151
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -126,17 +126,6 @@ public STuple<T2, T3, T4> Tail
126126
get { return new STuple<T2, T3, T4>(this.Item2, this.Item3, this.Item4); }
127127
}
128128

129-
void ITupleSerializable.PackTo(ref TupleWriter writer)
130-
{
131-
PackTo(ref writer);
132-
}
133-
134-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
135-
internal void PackTo(ref TupleWriter writer)
136-
{
137-
TupleSerializer<T1, T2, T3, T4>.Default.PackTo(ref writer, in this);
138-
}
139-
140129
ITuple ITuple.Append<T5>(T5 value)
141130
{
142131
// the caller doesn't care about the return type, so just box everything into a list tuple

FoundationDB.Client/Shared/Tuples/STuple`5.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace Doxense.Collections.Tuples
4646
/// <typeparam name="T4">Type of the 4th item</typeparam>
4747
/// <typeparam name="T5">Type of the 5th item</typeparam>
4848
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
49-
public readonly struct STuple<T1, T2, T3, T4, T5> : ITuple, ITupleSerializable, IEquatable<STuple<T1, T2, T3, T4, T5>>, IEquatable<(T1, T2, T3, T4, T5)>
49+
public readonly struct STuple<T1, T2, T3, T4, T5> : ITuple, IEquatable<STuple<T1, T2, T3, T4, T5>>, IEquatable<(T1, T2, T3, T4, T5)>
5050
{
5151
// This is mostly used by code that create a lot of temporary quartets, to reduce the pressure on the Garbage Collector by allocating them on the stack.
5252
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -132,17 +132,6 @@ public STuple<T2, T3, T4, T5> Tail
132132
get { return new STuple<T2, T3, T4, T5>(this.Item2, this.Item3, this.Item4, this.Item5); }
133133
}
134134

135-
void ITupleSerializable.PackTo(ref TupleWriter writer)
136-
{
137-
PackTo(ref writer);
138-
}
139-
140-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
141-
internal void PackTo(ref TupleWriter writer)
142-
{
143-
TupleSerializer<T1, T2, T3, T4, T5>.Default.PackTo(ref writer, in this);
144-
}
145-
146135
ITuple ITuple.Append<T6>(T6 value)
147136
{
148137
// the caller doesn't care about the return type, so just box everything into a list tuple

FoundationDB.Client/Shared/Tuples/STuple`6.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace Doxense.Collections.Tuples
4747
/// <typeparam name="T5">Type of the 5th item</typeparam>
4848
/// <typeparam name="T6">Type of the 5th item</typeparam>
4949
[ImmutableObject(true), DebuggerDisplay("{ToString(),nq}")]
50-
public readonly struct STuple<T1, T2, T3, T4, T5, T6> : ITuple, ITupleSerializable, IEquatable<STuple<T1, T2, T3, T4, T5, T6>>, IEquatable<(T1, T2, T3, T4, T5, T6)>
50+
public readonly struct STuple<T1, T2, T3, T4, T5, T6> : ITuple, IEquatable<STuple<T1, T2, T3, T4, T5, T6>>, IEquatable<(T1, T2, T3, T4, T5, T6)>
5151
{
5252
// This is mostly used by code that create a lot of temporary quartets, to reduce the pressure on the Garbage Collector by allocating them on the stack.
5353
// Please note that if you return an STuple<T> as an ITuple, it will be boxed by the CLR and all memory gains will be lost
@@ -138,17 +138,6 @@ public STuple<T2, T3, T4, T5, T6> Tail
138138
get { return new STuple<T2, T3, T4, T5, T6>(this.Item2, this.Item3, this.Item4, this.Item5, this.Item6); }
139139
}
140140

141-
void ITupleSerializable.PackTo(ref TupleWriter writer)
142-
{
143-
PackTo(ref writer);
144-
}
145-
146-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
147-
internal void PackTo(ref TupleWriter writer)
148-
{
149-
TupleSerializer<T1, T2, T3, T4, T5, T6>.Default.PackTo(ref writer, in this);
150-
}
151-
152141
ITuple ITuple.Append<T7>(T7 value)
153142
{
154143
// the caller doesn't care about the return type, so just box everything into a list tuple

0 commit comments

Comments
 (0)