Skip to content

Commit

Permalink
refactor: use bytes.Compare in primitive binary
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 25, 2023
1 parent d090a89 commit 861e198
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pkg/primitive/binary.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package primitive

import (
"bytes"
"encoding"
"fmt"
"reflect"
Expand Down Expand Up @@ -49,21 +50,7 @@ func (o Binary) Compare(v Object) int {
return -1
}
} else {
for i := 0; i < o.Len(); i++ {
if r.Len() == i {
return 1
}

v1 := o.Get(i)
v2 := r.Get(i)

if v1 > v2 {
return 1
} else if v1 < v2 {
return -1
}
}
return 0
return bytes.Compare(o.Bytes(), r.Bytes())
}
}

Expand Down

0 comments on commit 861e198

Please sign in to comment.