提交 2177b88f 编写于 作者: C CyrusNajmabadi

Add comments.

上级 a116090a
......@@ -27,11 +27,13 @@ public static ObjectBinderState AllocateStateCopy()
{
lock (s_gate)
{
// If we have any pooled copies, then just return one of those.
if (s_pool.Count > 0)
{
return s_pool.Pop();
}
// Otherwise, create copy from our current state and return that.
var state = ObjectBinderState.Create(s_version);
state.CopyFrom(s_state);
......@@ -43,6 +45,8 @@ public static void FreeStateCopy(ObjectBinderState state)
{
lock (s_gate)
{
// If our version changed between now and when we returned the state object,
// then we don't want to keep around this verion in the pool.
if (state.Version == s_version)
{
if (s_pool.Count < 128)
......
......@@ -29,13 +29,6 @@ internal struct ObjectBinderState
public static ObjectBinderState Create(int version)
=> new ObjectBinderState(version, new Dictionary<Type, int>(), new List<Type>(), new List<Func<ObjectReader, object>>());
public void Clear()
{
_typeToIndex.Clear();
_types.Clear();
_typeReaders.Clear();
}
public void CopyFrom(ObjectBinderState other)
{
if (_types.Count == 0)
......@@ -82,6 +75,7 @@ public bool RegisterTypeReader(Type type, Func<ObjectReader, object> typeReader)
{
if (_typeToIndex.ContainsKey(type))
{
// We already knew about this type, nothing to register.
return false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册