asmirnov82 commented on code in PR #13810:
URL: https://github.com/apache/arrow/pull/13810#discussion_r1158528568
##########
csharp/src/Apache.Arrow/Arrays/PrimitiveArrayBuilder.cs:
##########
@@ -141,15 +141,17 @@ public TBuilder Append(ReadOnlySpan<T> span)
{
int len = ValueBuffer.Length;
ValueBuffer.Append(span);
- ValidityBuffer.AppendRange(Enumerable.Repeat(true,
ValueBuffer.Length - len));
+ int additionalBitsCount = ValueBuffer.Length - len;
+
ValidityBuffer.Reserve(additionalBitsCount).AppendRange(Enumerable.Repeat(true,
additionalBitsCount));
Review Comment:
The idea was to reserve required memory once and later append all required
range of values. Current implemetation of AppendRange method appends values one
by one in a cycle, that may lead to several memory reallocations (that what I
was trying to avoid). AppendRange takes IEnumerable<bool> as parameter. So, now
I see only one way to get rid of Enumerable.Repeat - it is to use Append(bool)
in a cycle instead of using AppendRange. Is it what you would like me to do? Or
do you mean another approach?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]