summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/byte.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/byte.go b/lib/byte.go
index 149be2a..a29a7b0 100644
--- a/lib/byte.go
+++ b/lib/byte.go
@@ -16,11 +16,13 @@ func ByteInBytes(b byte, bs []byte) bool {
// Returns bytes that are common in the given array of array of bytes
// `bbytes`.
func BytesInCommon(bbytes [][]byte) []byte {
- common := make([]byte, 0)
+ var common []byte
switch l := len(bbytes); {
case l == 1:
- common = bbytes[0]
+ common = make([]byte, len(bbytes[0]))
+ copy(common, bbytes[0])
case l > 1:
+ common = make([]byte, 0)
commonRest := BytesInCommon(bbytes[1:])
for _, b := range bbytes[0] {
if ByteInBytes(b, commonRest) {