[#1642] tree: Refactor getSortedSubTree
Some checks failed
Vulncheck / Vulncheck (push) Successful in 1m8s
Pre-commit hooks / Pre-commit (push) Successful in 1m27s
Build / Build Components (push) Successful in 2m9s
Tests and linters / gopls check (push) Successful in 4m21s
Tests and linters / Run gofumpt (push) Successful in 4m29s
OCI image / Build container images (push) Successful in 4m48s
Tests and linters / Lint (push) Has been cancelled
Tests and linters / Tests (push) Has been cancelled
Tests and linters / Tests with -race (push) Has been cancelled
Tests and linters / Staticcheck (push) Has been cancelled

* Reuse `item` as result for `forest.TreeSortedByFilename`
  invocation.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2025-03-12 17:01:56 +03:00 committed by Evgenii Stratonikov
parent 39f549a7ab
commit a7ac30da9c

View file

@ -463,14 +463,13 @@ func getSortedSubTree(ctx context.Context, srv TreeService_GetSubTreeServer, cid
break
}
nodes, last, err := forest.TreeSortedByFilename(ctx, cid, b.GetTreeId(), item.parent, item.last, batchSize)
var err error
item.values, item.last, err = forest.TreeSortedByFilename(ctx, cid, b.GetTreeId(), item.parent, item.last, batchSize)
if err != nil {
return err
}
item.values = nodes
item.last = last
if len(nodes) == 0 {
if len(item.values) == 0 {
stack = stack[:len(stack)-1]
continue
}