instantiated: rename Drv method to Instantiated
This avoids confusion with actual derivation structs.
This commit is contained in:
parent
011958f108
commit
be2b069edf
@ -72,8 +72,8 @@ func NewInstantiatedDecoder(r io.Reader) *InstantiatedDecoder {
|
||||
return &InstantiatedDecoder{scanner: bufio.NewScanner(r)}
|
||||
}
|
||||
|
||||
// Drv returns a non-reusable iterator over instantiated derivations collected from [io.Reader].
|
||||
func (d *InstantiatedDecoder) Drv() iter.Seq[string] {
|
||||
// Instantiated returns a non-reusable iterator over instantiated derivations collected from [io.Reader].
|
||||
func (d *InstantiatedDecoder) Instantiated() iter.Seq[string] {
|
||||
return func(yield func(string) bool) {
|
||||
for d.scanner.Scan() {
|
||||
v := d.scanner.Text()
|
||||
@ -114,7 +114,7 @@ func (d *InstantiatedDecoder) Drv() iter.Seq[string] {
|
||||
// Decode collects and deduplicates derivations emitted by [InstantiatedDecoder].
|
||||
func (d *InstantiatedDecoder) Decode() ([]string, error) {
|
||||
instantiated := make([]string, 0, instantiatedInitialCap)
|
||||
for drv := range d.Drv() {
|
||||
for drv := range d.Instantiated() {
|
||||
if len(instantiated) == cap(instantiated) {
|
||||
// grow the buffer exponentially to minimise copies
|
||||
instantiated = slices.Grow(instantiated, cap(instantiated)<<1)
|
||||
|
@ -74,7 +74,7 @@ func TestDecodeInstantiated(t *testing.T) {
|
||||
decoder := nixbuild.NewInstantiatedDecoder(strings.NewReader(segmentPrefix + segmentBody + segmentSuffix))
|
||||
counter := 3
|
||||
got := make([]string, 0, counter)
|
||||
for drv := range decoder.Drv() {
|
||||
for drv := range decoder.Instantiated() {
|
||||
got = append(got, drv)
|
||||
counter--
|
||||
if counter == 0 {
|
||||
@ -83,7 +83,7 @@ func TestDecodeInstantiated(t *testing.T) {
|
||||
}
|
||||
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("Drv: %#v, want %#v", got, want)
|
||||
t.Errorf("Instantiated: %#v, want %#v", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user