Commit f6877d1 1 parent 66b6bcc commit f6877d1 Copy full SHA for f6877d1
File tree 1 file changed +6
-11
lines changed
1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -45,23 +45,18 @@ func New(cidrs ...netip.Prefix) Tree {
45
45
// Convenience function for initializing the cidrtree for large inputs (> 100_000).
46
46
// A good value reference for jobs is the number of logical CPUs [runtine.NumCPU] usable by the current process.
47
47
func NewConcurrent (jobs int , cidrs ... netip.Prefix ) Tree {
48
- if jobs <= 1 {
49
- return New (cidrs ... )
50
- }
48
+ // define a min chunk size, don't split in too small chunks
49
+ const minChunkSize = 25_000
51
50
51
+ // no fan-out for small input slice or just one job
52
52
l := len (cidrs )
53
-
54
- // define a min chunk size, don't split in too small chunks
55
- const minChunkSize = 10_000
53
+ if l < minChunkSize || jobs <= 1 {
54
+ return New ( cidrs ... )
55
+ }
56
56
57
57
chunkSize := l / jobs + 1
58
58
if chunkSize < minChunkSize {
59
59
chunkSize = minChunkSize
60
-
61
- // don't use go routine and result channel for just one chunk
62
- if l < chunkSize {
63
- return New (cidrs ... )
64
- }
65
60
}
66
61
67
62
var wg sync.WaitGroup
You can’t perform that action at this time.
0 commit comments