diff --git a/pkg/transformers/bar.go b/pkg/transformers/bar.go index f14bdd8ca..79a9abbfe 100644 --- a/pkg/transformers/bar.go +++ b/pkg/transformers/bar.go @@ -193,7 +193,7 @@ func NewTransformerBar( if doAuto { tr.recordTransformerFunc = tr.processAuto - tr.recordsForAutoMode = list.New() + tr.recordsForAutoMode = types.NewList[*types.RecordAndContext](10) // XXX size } else { tr.recordTransformerFunc = tr.processNoAuto tr.recordsForAutoMode = nil @@ -270,9 +270,8 @@ func (tr *TransformerBar) processAuto( // The first pass computes lo and hi from the data onFirst := true - for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() { - recordAndContexts := e.Value.(*types.RecordAndContext) - record := recordAndContexts.Record + for _, recordAndContext := range tr.recordsForAutoMode.Items { + record := recordAndContext.Record mvalue := record.Get(fieldName) if mvalue == nil { continue @@ -300,8 +299,7 @@ func (tr *TransformerBar) processAuto( slo := fmt.Sprintf("%g", lo) shi := fmt.Sprintf("%g", hi) - for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() { - recordAndContext := e.Value.(*types.RecordAndContext) + for _, recordAndContext := range tr.recordsForAutoMode.Items { record := recordAndContext.Record mvalue := record.Get(fieldName) if mvalue == nil { @@ -332,10 +330,6 @@ func (tr *TransformerBar) processAuto( } } - for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() { - recordAndContext := e.Value.(*types.RecordAndContext) - outputRecordsAndContexts.PushBack(recordAndContext) - } - + outputRecordsAndContexts.PushBackMultiple(tr.recordsForAutoMode.Items) outputRecordsAndContexts.PushBack(inrecAndContext) // Emit the end-of-stream marker } diff --git a/pkg/transformers/bootstrap.go b/pkg/transformers/bootstrap.go index dcd319d55..12f769414 100644 --- a/pkg/transformers/bootstrap.go +++ b/pkg/transformers/bootstrap.go @@ -96,7 +96,7 @@ type TransformerBootstrap struct { func NewTransformerBootstrap(nout int64) (*TransformerBootstrap, error) { tr := &TransformerBootstrap{ - recordsAndContexts: list.New(), + recordsAndContexts: types.NewList[*types.RecordAndContext](int(100)), // XXX size nout: nout, } return tr, nil diff --git a/pkg/transformers/count_similar.go b/pkg/transformers/count_similar.go index 8610dda8c..49bfc52a3 100644 --- a/pkg/transformers/count_similar.go +++ b/pkg/transformers/count_similar.go @@ -160,6 +160,7 @@ func (tr *TransformerCountSimilar) Transform( } } - outputRecordsAndContexts.PushBack(inrecAndContext) // Emit the stream-terminating null record + // Emit the stream-terminating null record + outputRecordsAndContexts.PushBack(inrecAndContext) } } diff --git a/pkg/transformers/fraction.go b/pkg/transformers/fraction.go index df76fde27..bf64e6928 100644 --- a/pkg/transformers/fraction.go +++ b/pkg/transformers/fraction.go @@ -150,7 +150,7 @@ func NewTransformerFraction( doCumu bool, ) (*TransformerFraction, error) { - recordsAndContexts := list.New() + recordsAndContexts := types.NewList[*types.RecordAndContext](100) // XXX SIZE sums := make(map[string]map[string]*mlrval.Mlrval) cumus := make(map[string]map[string]*mlrval.Mlrval) diff --git a/pkg/transformers/rename.go b/pkg/transformers/rename.go index 285535d9e..35f2290a3 100644 --- a/pkg/transformers/rename.go +++ b/pkg/transformers/rename.go @@ -134,7 +134,7 @@ type tRegexAndReplacement struct { type TransformerRename struct { oldToNewNames *lib.OrderedMap - regexesAndReplacements *list.List + regexesAndReplacements *types.List[*tRegexAndReplacement] doGsub bool recordTransformerFunc RecordTransformerFunc } @@ -163,7 +163,7 @@ func NewTransformerRename( tr.doGsub = false tr.recordTransformerFunc = tr.transformWithoutRegexes } else { - tr.regexesAndReplacements = list.New() + tr.regexesAndReplacements = types.NewList[*tRegexAndReplacement](10) for pe := oldToNewNames.Head; pe != nil; pe = pe.Next { regexString := pe.Key regex := lib.CompileMillerRegexOrDie(regexString) diff --git a/pkg/transformers/sort.go b/pkg/transformers/sort.go index cba7dbfcc..2102a2abf 100644 --- a/pkg/transformers/sort.go +++ b/pkg/transformers/sort.go @@ -309,7 +309,8 @@ type TransformerSort struct { recordListsByGroup *lib.OrderedMap // Map from string to []*lib.Mlrval: groupHeads *lib.OrderedMap - spillGroup *list.List // e.g. sort by field "a" -- this is for records lacking a field named "a" + // E.g. for sort by field "a", this is for records lacking a field named "a" + spillGroup *types.List[*types.RecordAndContext] } func NewTransformerSort(