public T[] Deserialize(ref JsonReader <TSymbol> reader) { T[] temp = null; T[] result; try { temp = ArrayPool <T> .Shared.Rent(4); reader.ReadBeginArrayOrThrow(); var count = 0; while (!reader.TryReadIsEndArrayOrValueSeparator(ref count)) // count is already preincremented, as it counts the separators { if (count == temp.Length) { FormatterUtils.Grow(ref temp); } temp[count - 1] = ElementFormatter.Deserialize(ref reader); } if (count == 0) { result = Array.Empty <T>(); } else { result = new T[count]; Array.Copy(temp, result, count); } } finally { if (temp != null) { ArrayPool <T> .Shared.Return(temp); } } return(result); }