func prunePermissionSeq(nodes []*permissionNode, prune map[string]bool) (result []*permissionNode, err os.Error) { for _, n := range nodes { // This mutation/permission is not to be pruned? if _, is_prune := prune[n.BlobRef()]; !is_prune { p := *n p.Permission, err = ot.PrunePermission(n.Permission, prune) result = append(result, &p) if err != nil { return } } } return }
func pruneSeq(nodes []otNode, prune map[string]bool) (result []otNode, err os.Error) { started := false var u ot.Mutation for _, n := range nodes { // This mutation/permission is not to be pruned? if _, isundo := prune[n.BlobRef()]; !isundo { if started { // Started pruning? switch n.(type) { case *permissionNode: p := *(n.(*permissionNode)) p.permission, err = ot.PrunePermission(n.(*permissionNode).permission, prune) result = append(result, &p) case *mutationNode: m := *(n.(*mutationNode)) m.mutation, u, err = ot.PruneMutation(n.(*mutationNode).mutation, u) result = append(result, &m) case *keepNode: result = append(result, n) } if err != nil { return } } else { // Pruning did not yet start. Just append 'n' to the result result = append(result, n) } continue } switch n.(type) { case *permissionNode, *keepNode: // Ignore the permission node // Do nothing by intention case *mutationNode: // Store in u that the mutation in 'n' are pruned. if !started { // Initialize 'u' started = true u = n.(*mutationNode).mutation } else { // Add the mutation of node 'n' to 'u' u, err = ot.Compose(u, n.(*mutationNode).mutation) if err != nil { return } } } } return }