types/views: add SliceView.All iterator (#13536)

And convert a all relevant usages.

Updates #12912

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2024-09-20 13:55:33 -07:00
committed by GitHub
parent 3e9ca6c64b
commit dc86d3589c
4 changed files with 50 additions and 10 deletions

View File

@@ -93,8 +93,7 @@ func (b *LocalBackend) driveSetShareLocked(share *drive.Share) (views.SliceView[
addedShare := false
var shares []*drive.Share
for i := range existingShares.Len() {
existing := existingShares.At(i)
for _, existing := range existingShares.All() {
if existing.Name() != share.Name {
if !addedShare && existing.Name() > share.Name {
// Add share in order
@@ -152,8 +151,7 @@ func (b *LocalBackend) driveRenameShareLocked(oldName, newName string) (views.Sl
found := false
var shares []*drive.Share
for i := range existingShares.Len() {
existing := existingShares.At(i)
for _, existing := range existingShares.All() {
if existing.Name() == newName {
return existingShares, os.ErrExist
}
@@ -213,8 +211,7 @@ func (b *LocalBackend) driveRemoveShareLocked(name string) (views.SliceView[*dri
found := false
var shares []*drive.Share
for i := range existingShares.Len() {
existing := existingShares.At(i)
for _, existing := range existingShares.All() {
if existing.Name() != name {
shares = append(shares, existing.AsStruct())
} else {