forgejo_backup/modules/util
oliverpool 31ad7c9353 blob: GetBlobContent: reduce allocations (#8223)
See #8222 for context.

## git.Blob.NewTruncatedReader

This introduce a new `NewTruncatedReader` method to return a blob-reader which silently truncates when the limit is reached (io.EOF will be returned).
Since the actual size is also returned `GetBlobContent` can pre-allocate a `[]byte` of the full-size (min of the asked size and the actual size) and call `io.ReadFull(rc, buf)` (instead of `util.ReadWithLimit(dataRc, int(limit))` which is convoluted and not used anywhere else).

### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.

### Documentation

- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] I do not want this change to show in the release notes.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8223
Reviewed-by: Lucas <sclu1034@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: oliverpool <git@olivier.pfad.fr>
Co-committed-by: oliverpool <git@olivier.pfad.fr>
2025-06-19 18:36:12 +02:00
..
filebuffer
rotatingfilewriter chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
color.go
color_test.go
error.go
file_unix.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
file_unix_test.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
io.go blob: GetBlobContent: reduce allocations (#8223) 2025-06-19 18:36:12 +02:00
keypair.go
keypair_test.go
legacy.go
legacy_test.go
pack.go
pack_test.go
paginate.go
paginate_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
path.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
path_test.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
remove.go Drop SSPI auth support and more Windows files (#7148) 2025-03-08 00:43:41 +00:00
sanitize.go
sanitize_test.go
sec_to_time.go
sec_to_time_test.go
shellquote.go
shellquote_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
slice.go chore: teach set module about iter.Seq (#6676) 2025-01-24 16:45:46 +00:00
slice_test.go
string.go
string_test.go
timer.go
timer_test.go
truncate.go [gitea] week 2025-22 cherry pick (gitea/main -> forgejo) (#8198) 2025-06-17 18:28:07 +02:00
truncate_test.go [gitea] week 2025-22 cherry pick (gitea/main -> forgejo) (#8198) 2025-06-17 18:28:07 +02:00
url.go
util.go chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00
util_test.go chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00