Browse Source

A bit of safety

Loweel 4 years ago
parent
commit
90fcd9275e
1 changed files with 1 additions and 5 deletions
  1. 1 5
      matrix.go

+ 1 - 5
matrix.go

@@ -180,10 +180,6 @@ func (c *ByClassifier) enroll() {
 
 func sortMap(unsorted *sync.Map, size int) {
 
-	if size == 0 {
-		size = 1
-	}
-
 	type Myt struct {
 		Name string
 		Num  int64
@@ -201,7 +197,7 @@ func sortMap(unsorted *sync.Map, size int) {
 
 	sort.Slice(tempCont, func(i, j int) bool { return tempCont[i].Num > tempCont[j].Num })
 
-	if len(tempCont) > size {
+	if len(tempCont) > size && size > 0 {
 		tempCont = tempCont[:size]
 	}