aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go')
-rw-r--r--vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
index 598b40460..16cbfb56f 100644
--- a/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
+++ b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
@@ -14,22 +14,19 @@ const (
vlqContinuationBit = vlqBase
)
-var (
- decodeMap [256]int
-)
+var decodeMap [256]byte
func init() {
for i := 0; i < len(encodeStd); i++ {
- decodeMap[encodeStd[i]] = i
+ decodeMap[encodeStd[i]] = byte(i)
}
}
func toVLQSigned(n int) int {
if n < 0 {
return -n<<1 + 1
- } else {
- return n << 1
}
+ return n << 1
}
func fromVLQSigned(n int) int {
@@ -51,7 +48,7 @@ func NewEncoder(w io.ByteWriter) *Encoder {
}
}
-func (enc *Encoder) Encode(n int) error {
+func (enc Encoder) Encode(n int) error {
n = toVLQSigned(n)
for digit := vlqContinuationBit; digit&vlqContinuationBit != 0; {
digit = n & vlqBaseMask
@@ -59,6 +56,7 @@ func (enc *Encoder) Encode(n int) error {
if n > 0 {
digit |= vlqContinuationBit
}
+
err := enc.w.WriteByte(encodeStd[digit])
if err != nil {
return err
@@ -77,7 +75,7 @@ func NewDecoder(r io.ByteReader) *Decoder {
}
}
-func (dec *Decoder) Decode() (n int, err error) {
+func (dec Decoder) Decode() (n int, err error) {
shift := uint(0)
for continuation := true; continuation; {
c, err := dec.r.ReadByte()
@@ -85,10 +83,9 @@ func (dec *Decoder) Decode() (n int, err error) {
return 0, err
}
- digit := decodeMap[c]
- continuation = digit&vlqContinuationBit != 0
- digit &= vlqBaseMask
- n = n + digit<<shift
+ c = decodeMap[c]
+ continuation = c&vlqContinuationBit != 0
+ n += int(c&vlqBaseMask) << shift
shift += vlqBaseShift
}
return fromVLQSigned(n), nil