Resets object on return instead of on rent.

This commit is contained in:
2023-04-19 13:32:06 +08:00
parent cf6a7a795b
commit 0f683e403c

View File

@@ -28,7 +28,6 @@ namespace Cryville.Common.Buffers {
_objs[_index++] = null;
}
if (obj == null) obj = Construct();
else Reset(obj);
return obj;
}
/// <summary>
@@ -36,7 +35,10 @@ namespace Cryville.Common.Buffers {
/// </summary>
/// <param name="obj">The object to return.</param>
public void Return(T obj) {
if (_index > 0) _objs[--_index] = obj;
if (_index > 0) {
Reset(obj);
_objs[--_index] = obj;
}
}
/// <summary>
/// Constructs a new instance of type <typeparamref name="T" />.