diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-04-29 12:49:39 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-04-29 15:17:26 +0300 |
commit | aec9c277dff3655de6fb38210db0ec6aef14ac99 (patch) | |
tree | a590161b8267fba796c37bf6d8c17a63d31e1556 | |
parent | f86bbd698a2d728dbf684b034eecf0c3c1a5486b (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 2902c01dc..6789f99d0 100644 --- a/internal/gitaly/service/commit/check_objects_exist.go +++ b/internal/gitaly/service/commit/check_objects_exist.go @@ -83,7 +83,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) { |