Skip to content

Commit 3015222

Browse files
committed
code cleanup
1 parent 9403231 commit 3015222

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

adif/cabrillo.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,18 @@ func (o *CabrilloIO) getCategories(l *Logfile) map[string]string {
374374
}
375375

376376
func (o *CabrilloIO) toConfig() cabrilloConfig {
377-
c := cabrilloConfig{fields: make(CabrilloFieldList, 0), useTabs: o.TabDelimiter,
378-
coreLen: len(cabCoreFields), myLen: len(o.MyExchange) + 1, theirLen: len(o.TheirExchange) + 1, extraLen: len(o.ExtraFields)}
379-
c.fields = append(c.fields, cabCoreFields...)
380377
myCall := cabFieldMyCall
381378
if o.Callsign != "" {
382379
myCall.Default = o.Callsign
383380
}
381+
c := cabrilloConfig{
382+
useTabs: o.TabDelimiter,
383+
coreLen: len(cabCoreFields),
384+
myLen: len(o.MyExchange) + 1,
385+
theirLen: len(o.TheirExchange) + 1,
386+
extraLen: len(o.ExtraFields)}
387+
// TODO use slices.Concat in go1.22
388+
c.fields = append(c.fields, cabCoreFields...)
384389
c.fields = append(c.fields, myCall)
385390
c.fields = append(c.fields, o.MyExchange...)
386391
c.fields = append(c.fields, cabFieldTheirCall)
@@ -792,8 +797,7 @@ func (l *CabrilloFieldList) Get() any { return *l }
792797

793798
type cabrilloConfig struct {
794799
// core, my, their, extra
795-
fields CabrilloFieldList
796-
// TODO just have four lists of fields and a method to combine them?
800+
fields CabrilloFieldList
797801
coreLen, myLen, theirLen, extraLen int
798802
useTabs bool
799803
}
@@ -876,7 +880,6 @@ func (c cabrilloConfig) toLines(l *Logfile) ([][2]string, error) {
876880
}
877881
return r.String()
878882
}
879-
// TODO this would be better with four field slices and a method to combine a slice
880883
var corelen, sentlen, rcvdlen int
881884
for i := 0; i < c.coreLen; i++ {
882885
corelen += widths[i]

0 commit comments

Comments
 (0)