diff options
Diffstat (limited to 'skate')
-rw-r--r-- | skate/reduce.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/skate/reduce.go b/skate/reduce.go index ff836e8..a7a6d8a 100644 --- a/skate/reduce.go +++ b/skate/reduce.go @@ -10,8 +10,11 @@ // the readers (and string groups): release, ref, ref-as-release, open library, // wikipedia, ... // -// TODO: [ ] pass release stage through all match types -// TODO: [ ] switch to faster logging, e.g. zerolog, https://github.com/rs/zerolog#benchmarks +// TODO: +// * [ ] pass release stage through all match types +// * [ ] switch to faster logging, e.g. zerolog, https://github.com/rs/zerolog#benchmarks +// * [ ] batch, parallelize +// * [ ] unify flags to "-a", "-b" package skate import ( @@ -35,6 +38,20 @@ var brefPool = sync.Pool{ }, } +var releasePool = sync.Pool{ + New: func() interface{} { + var r Release + return &r + }, +} + +var refPool = sync.Pool{ + New: func() interface{} { + var r Ref + return &r + }, +} + // groupLogf logs a message alongsize a serialized group for debugging. func groupLogf(g *zipkey.Group, s string, vs ...interface{}) { log.Printf(s, vs...) @@ -56,10 +73,12 @@ func ZippyExact(releases, refs io.Reader, matchResult MatchResult, w io.Writer) log.Printf("processed %v groups", i) } var ( - target *Release - ref *Ref + target = releasePool.Get().(*Release) + ref = refPool.Get().(*Ref) err error ) + defer releasePool.Put(target) + defer refPool.Put(ref) if len(g.G0) == 0 || len(g.G1) == 0 { return nil } @@ -73,6 +92,7 @@ func ZippyExact(releases, refs io.Reader, matchResult MatchResult, w io.Writer) continue } bref = brefPool.Get().(BiblioRef) + defer brefPool.Put(bref) bref.Reset() bref.SourceReleaseIdent = ref.ReleaseIdent bref.SourceWorkIdent = ref.WorkIdent @@ -88,7 +108,6 @@ func ZippyExact(releases, refs io.Reader, matchResult MatchResult, w io.Writer) if err := enc.Encode(bref); err != nil { return err } - brefPool.Put(bref) } return nil } |