VOL-1984 Migrate voltha-simolt-adapter to go mod

Change-Id: I8c167fb179b699b9cea02e36c20e1d28db61f41a
diff --git a/vendor/github.com/pierrec/lz4/block.go b/vendor/github.com/pierrec/lz4/block.go
index d96e0e7..ef24f17 100644
--- a/vendor/github.com/pierrec/lz4/block.go
+++ b/vendor/github.com/pierrec/lz4/block.go
@@ -30,17 +30,75 @@
 // The destination buffer must be sized appropriately.
 //
 // An error is returned if the source data is invalid or the destination buffer is too small.
-func UncompressBlock(src, dst []byte) (di int, err error) {
+func UncompressBlock(src, dst []byte) (si int, err error) {
+	defer func() {
+		// It is now faster to let the runtime panic and recover on out of bound slice access
+		// than checking indices as we go along.
+		if recover() != nil {
+			err = ErrInvalidSourceShortBuffer
+		}
+	}()
 	sn := len(src)
 	if sn == 0 {
 		return 0, nil
 	}
+	var di int
 
-	di = decodeBlock(dst, src)
-	if di < 0 {
-		return 0, ErrInvalidSourceShortBuffer
+	for {
+		// Literals and match lengths (token).
+		b := int(src[si])
+		si++
+
+		// Literals.
+		if lLen := b >> 4; lLen > 0 {
+			if lLen == 0xF {
+				for src[si] == 0xFF {
+					lLen += 0xFF
+					si++
+				}
+				lLen += int(src[si])
+				si++
+			}
+			i := si
+			si += lLen
+			di += copy(dst[di:], src[i:si])
+
+			if si >= sn {
+				return di, nil
+			}
+		}
+
+		si++
+		_ = src[si] // Bound check elimination.
+		offset := int(src[si-1]) | int(src[si])<<8
+		si++
+
+		// Match.
+		mLen := b & 0xF
+		if mLen == 0xF {
+			for src[si] == 0xFF {
+				mLen += 0xFF
+				si++
+			}
+			mLen += int(src[si])
+			si++
+		}
+		mLen += minMatch
+
+		// Copy the match.
+		i := di - offset
+		if offset > 0 && mLen >= offset {
+			// Efficiently copy the match dst[di-offset:di] into the dst slice.
+			bytesToCopy := offset * (mLen / offset)
+			expanded := dst[i:]
+			for n := offset; n <= bytesToCopy+offset; n *= 2 {
+				copy(expanded[n:], expanded[:n])
+			}
+			di += bytesToCopy
+			mLen -= bytesToCopy
+		}
+		di += copy(dst[di:], dst[i:i+mLen])
 	}
-	return di, nil
 }
 
 // CompressBlock compresses the source buffer into the destination one.
@@ -128,7 +186,7 @@
 		di++
 
 		// Literals.
-		copy(dst[di:di+lLen], src[anchor:anchor+lLen])
+		copy(dst[di:], src[anchor:anchor+lLen])
 		di += lLen + 2
 		anchor = si
 
@@ -172,7 +230,7 @@
 		// Incompressible.
 		return 0, nil
 	}
-	di += copy(dst[di:di+len(src)-anchor], src[anchor:])
+	di += copy(dst[di:], src[anchor:])
 	return di, nil
 }
 
@@ -228,7 +286,7 @@
 			for ml < sn-si && src[next+ml] == src[si+ml] {
 				ml++
 			}
-			if ml < minMatch || ml <= mLen {
+			if ml+1 < minMatch || ml <= mLen {
 				// Match too small (<minMath) or smaller than the current match.
 				continue
 			}
@@ -289,7 +347,7 @@
 		di++
 
 		// Literals.
-		copy(dst[di:di+lLen], src[anchor:anchor+lLen])
+		copy(dst[di:], src[anchor:anchor+lLen])
 		di += lLen
 		anchor = si
 
@@ -334,6 +392,6 @@
 		// Incompressible.
 		return 0, nil
 	}
-	di += copy(dst[di:di+len(src)-anchor], src[anchor:])
+	di += copy(dst[di:], src[anchor:])
 	return di, nil
 }