Browse Source

ConcurrencyOption: use all procs for n <= 0

Signed-off-by: Pierre.Curto <pierre.curto@gmail.com>
Pierre.Curto 5 years ago
parent
commit
04465be83d
1 changed files with 3 additions and 7 deletions
  1. 3 7
      options.go

+ 3 - 7
options.go

@@ -110,7 +110,7 @@ func SizeOption(size uint64) Option {
 }
 
 // ConcurrencyOption sets the number of go routines used for compression.
-// If n<0, then the output of runtime.GOMAXPROCS(0) is used.
+// If n <= 0, then the output of runtime.GOMAXPROCS(0) is used.
 func ConcurrencyOption(n int) Option {
 	return func(a applier) error {
 		switch w := a.(type) {
@@ -118,12 +118,8 @@ func ConcurrencyOption(n int) Option {
 			s := fmt.Sprintf("ConcurrencyOption(%d)", n)
 			return lz4errors.Error(s)
 		case *Writer:
-			switch n {
-			case 0, 1:
-			default:
-				if n < 0 {
-					n = runtime.GOMAXPROCS(0)
-				}
+			if n <= 0 {
+				n = runtime.GOMAXPROCS(0)
 			}
 			w.num = n
 			return nil