diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-04-29 12:49:39 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-03 08:48:45 +0300 |
commit | bb1c2baba8ad5a72715d01c7b9820e2a4563469b (patch) | |
tree | 702dd77de2450ebf21b25cc9c961122affc5fca7 | |
parent | a28046ec205c2efac8105edac0b61614d7db5d97 (diff) |
commit: Avoid reallocating result array when sending object existence
The sender we're using for chunked responses in `CheckObjectsExists()`
is reallocating the result array every time we have sent out a message.
This is needlessly wasteful though: we can just truncate the array and
thus avoid a memory allocation. It's likely not going to matter much in
this context, but the end result is easier to read, too.
-rw-r--r-- | internal/gitaly/service/commit/check_objects_exist.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/internal/gitaly/service/commit/check_objects_exist.go b/internal/gitaly/service/commit/check_objects_exist.go index 1295bf76c..653c57132 100644 --- a/internal/gitaly/service/commit/check_objects_exist.go +++ b/internal/gitaly/service/commit/check_objects_exist.go @@ -84,7 +84,7 @@ func (c *checkObjectsExistSender) Send() error { } func (c *checkObjectsExistSender) Reset() { - c.revisions = make([]*gitalypb.CheckObjectsExistResponse_RevisionExistence, 0) + c.revisions = c.revisions[:0] } func (c *checkObjectsExistSender) Append(m proto.Message) { |