Skip to content

Commit c9fc90e

Browse files
committed
optimization
1 parent 853747c commit c9fc90e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/TableStorage.Abstractions.POCO/PocoTableStore.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ namespace TableStorage.Abstractions.POCO
1616
{
1717
public class PocoTableStore<T, TPartitionKey, TRowKey> : IPocoTableStore<T, TPartitionKey, TRowKey> where T : class, new()
1818
{
19-
//hack because this is internal. Need to get this exposed.
20-
private static readonly ConcurrentDictionary<Type, ConstructorInfo> _pagedResultConstructors =
21-
new ConcurrentDictionary<Type, ConstructorInfo>();
22-
2319

2420
private readonly IKeysConverter<T, TPartitionKey, TRowKey> _keysConverter;
2521
private readonly TableStore<DynamicTableEntity> _tableStore;
@@ -1104,12 +1100,12 @@ private IEnumerable<T> CreateRecords(IEnumerable<DynamicTableEntity> entities)
11041100
//this whole method is a hack, will be removed when PagedResult can be directly invoked.
11051101
private PagedResult<T> CreatePagedResult(PagedResult<DynamicTableEntity> result, Func<T, bool> filter = null)
11061102
{
1107-
_pagedResultConstructors.TryGetValue(typeof(T), out ConstructorInfo ctor);
1103+
PagedResultCache.PagedResultConstructors.TryGetValue(typeof(T), out ConstructorInfo ctor);
11081104
if (ctor == null)
11091105
{
11101106
var t = typeof(PagedResult<T>);
11111107
ctor = t.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single();
1112-
_pagedResultConstructors.TryAdd(t, ctor);
1108+
PagedResultCache.PagedResultConstructors.TryAdd(t, ctor);
11131109
}
11141110

11151111
var records = CreateRecords(result.Items);
@@ -1147,5 +1143,11 @@ private string GetRowKeyString(TRowKey key)
11471143

11481144

11491145

1146+
}
1147+
1148+
internal static class PagedResultCache
1149+
{
1150+
public static ConcurrentDictionary<Type, ConstructorInfo> PagedResultConstructors { get; } =
1151+
new ConcurrentDictionary<Type, ConstructorInfo>();
11501152
}
11511153
}

0 commit comments

Comments
 (0)