instantiated: rename Drv method to Instantiated

This avoids confusion with actual derivation structs.
This commit is contained in:
Yonah 2025-07-14 22:34:44 +09:00
parent 011958f108
commit be2b069edf
Signed by: yonah
SSH Key Fingerprint: SHA256:vnQvK8+XXH9Tbni2AV1a/8qdVK/zPcXw52GM0ruQvwA
2 changed files with 5 additions and 5 deletions

View File

@ -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)

View File

@ -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)
}
})