perf(grpc): O(1) unconstrained bulk fast path, direct filtered-command build, cache eviction, capacity hints
This commit is contained in:
@@ -120,6 +120,10 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Boolean:
|
||||
{
|
||||
BoolArray values = new();
|
||||
|
||||
// Size the backing store once: the fill below adds exactly `length` elements,
|
||||
// so without this the RepeatedField doubles its array log2(length) times.
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(false);
|
||||
@@ -137,6 +141,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Integer when UsesInt64(elements):
|
||||
{
|
||||
Int64Array values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(0L);
|
||||
@@ -154,6 +159,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Integer:
|
||||
{
|
||||
Int32Array values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(0);
|
||||
@@ -171,6 +177,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Float:
|
||||
{
|
||||
FloatArray values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(0f);
|
||||
@@ -188,6 +195,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Double:
|
||||
{
|
||||
DoubleArray values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(0d);
|
||||
@@ -205,6 +213,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.String:
|
||||
{
|
||||
StringArray values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(string.Empty);
|
||||
@@ -222,6 +231,7 @@ internal static class SparseArrayExpander
|
||||
case MxDataType.Time:
|
||||
{
|
||||
TimestampArray values = new();
|
||||
values.Values.Capacity = length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
values.Values.Add(new Timestamp { Seconds = 0, Nanos = 0 });
|
||||
|
||||
Reference in New Issue
Block a user