mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Grand test fixup (#138)
* start fixing up tests * fix up tests + automate with drone * fiddle with linting * messing about with drone.yml * some more fiddling * hmmm * add cache * add vendor directory * verbose * ci updates * update some little things * update sig
This commit is contained in:
11
vendor/github.com/tmthrgd/go-hex/.travis.yml
generated
vendored
Normal file
11
vendor/github.com/tmthrgd/go-hex/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.12.x
|
||||
- 1.13.x
|
||||
- tip
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- go: tip
|
82
vendor/github.com/tmthrgd/go-hex/LICENSE
generated
vendored
Normal file
82
vendor/github.com/tmthrgd/go-hex/LICENSE
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
Copyright (c) 2016, Tom Thorogood.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Tom Thorogood nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Portions of the source code are also covered by the following license: ----
|
||||
|
||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---- Portions of the source code are also covered by the following license: ----
|
||||
|
||||
Copyright (c) 2005-2016, Wojciech Muła
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
108
vendor/github.com/tmthrgd/go-hex/README.md
generated
vendored
Normal file
108
vendor/github.com/tmthrgd/go-hex/README.md
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
# go-hex
|
||||
|
||||
[](https://godoc.org/github.com/tmthrgd/go-hex)
|
||||
[](https://travis-ci.org/tmthrgd/go-hex)
|
||||
|
||||
An efficient hexadecimal implementation for Golang.
|
||||
|
||||
go-hex provides hex encoding and decoding using SSE/AVX instructions on x86-64.
|
||||
|
||||
## Download
|
||||
|
||||
```
|
||||
go get github.com/tmthrgd/go-hex
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
|
||||
go-hex:
|
||||
```
|
||||
BenchmarkEncode/15-8 100000000 17.4 ns/op 863.43 MB/s
|
||||
BenchmarkEncode/32-8 100000000 11.9 ns/op 2690.43 MB/s
|
||||
BenchmarkEncode/128-8 100000000 21.4 ns/op 5982.92 MB/s
|
||||
BenchmarkEncode/1k-8 20000000 88.5 ns/op 11572.80 MB/s
|
||||
BenchmarkEncode/16k-8 1000000 1254 ns/op 13058.10 MB/s
|
||||
BenchmarkEncode/128k-8 100000 12965 ns/op 10109.53 MB/s
|
||||
BenchmarkEncode/1M-8 10000 119465 ns/op 8777.23 MB/s
|
||||
BenchmarkEncode/16M-8 500 3530380 ns/op 4752.24 MB/s
|
||||
BenchmarkEncode/128M-8 50 28001913 ns/op 4793.16 MB/s
|
||||
BenchmarkDecode/14-8 100000000 12.6 ns/op 1110.01 MB/s
|
||||
BenchmarkDecode/32-8 100000000 12.5 ns/op 2558.10 MB/s
|
||||
BenchmarkDecode/128-8 50000000 27.2 ns/op 4697.66 MB/s
|
||||
BenchmarkDecode/1k-8 10000000 168 ns/op 6093.43 MB/s
|
||||
BenchmarkDecode/16k-8 500000 2543 ns/op 6442.09 MB/s
|
||||
BenchmarkDecode/128k-8 100000 20339 ns/op 6444.24 MB/s
|
||||
BenchmarkDecode/1M-8 10000 164313 ns/op 6381.57 MB/s
|
||||
BenchmarkDecode/16M-8 500 3099822 ns/op 5412.31 MB/s
|
||||
BenchmarkDecode/128M-8 50 24865822 ns/op 5397.68 MB/s
|
||||
```
|
||||
|
||||
[encoding/hex](https://golang.org/pkg/encoding/hex/):
|
||||
```
|
||||
BenchmarkRefEncode/15-8 50000000 36.1 ns/op 415.07 MB/s
|
||||
BenchmarkRefEncode/32-8 20000000 72.9 ns/op 439.14 MB/s
|
||||
BenchmarkRefEncode/128-8 5000000 289 ns/op 441.54 MB/s
|
||||
BenchmarkRefEncode/1k-8 1000000 2268 ns/op 451.49 MB/s
|
||||
BenchmarkRefEncode/16k-8 30000 39110 ns/op 418.91 MB/s
|
||||
BenchmarkRefEncode/128k-8 5000 291260 ns/op 450.02 MB/s
|
||||
BenchmarkRefEncode/1M-8 1000 2277578 ns/op 460.39 MB/s
|
||||
BenchmarkRefEncode/16M-8 30 37087543 ns/op 452.37 MB/s
|
||||
BenchmarkRefEncode/128M-8 5 293611713 ns/op 457.13 MB/s
|
||||
BenchmarkRefDecode/14-8 30000000 53.7 ns/op 260.49 MB/s
|
||||
BenchmarkRefDecode/32-8 10000000 128 ns/op 248.44 MB/s
|
||||
BenchmarkRefDecode/128-8 3000000 481 ns/op 265.95 MB/s
|
||||
BenchmarkRefDecode/1k-8 300000 4172 ns/op 245.43 MB/s
|
||||
BenchmarkRefDecode/16k-8 10000 111989 ns/op 146.30 MB/s
|
||||
BenchmarkRefDecode/128k-8 2000 909077 ns/op 144.18 MB/s
|
||||
BenchmarkRefDecode/1M-8 200 7275779 ns/op 144.12 MB/s
|
||||
BenchmarkRefDecode/16M-8 10 116574839 ns/op 143.92 MB/s
|
||||
BenchmarkRefDecode/128M-8 2 933871637 ns/op 143.72 MB/s
|
||||
```
|
||||
|
||||
[encoding/hex](https://golang.org/pkg/encoding/hex/) -> go-hex:
|
||||
```
|
||||
benchmark old ns/op new ns/op delta
|
||||
BenchmarkEncode/15-8 36.1 17.4 -51.80%
|
||||
BenchmarkEncode/32-8 72.9 11.9 -83.68%
|
||||
BenchmarkEncode/128-8 289 21.4 -92.60%
|
||||
BenchmarkEncode/1k-8 2268 88.5 -96.10%
|
||||
BenchmarkEncode/16k-8 39110 1254 -96.79%
|
||||
BenchmarkEncode/128k-8 291260 12965 -95.55%
|
||||
BenchmarkEncode/1M-8 2277578 119465 -94.75%
|
||||
BenchmarkEncode/16M-8 37087543 3530380 -90.48%
|
||||
BenchmarkEncode/128M-8 293611713 28001913 -90.46%
|
||||
BenchmarkDecode/14-8 53.7 12.6 -76.54%
|
||||
BenchmarkDecode/32-8 128 12.5 -90.23%
|
||||
BenchmarkDecode/128-8 481 27.2 -94.35%
|
||||
BenchmarkDecode/1k-8 4172 168 -95.97%
|
||||
BenchmarkDecode/16k-8 111989 2543 -97.73%
|
||||
BenchmarkDecode/128k-8 909077 20339 -97.76%
|
||||
BenchmarkDecode/1M-8 7275779 164313 -97.74%
|
||||
BenchmarkDecode/16M-8 116574839 3099822 -97.34%
|
||||
BenchmarkDecode/128M-8 933871637 24865822 -97.34%
|
||||
|
||||
benchmark old MB/s new MB/s speedup
|
||||
BenchmarkEncode/15-8 415.07 863.43 2.08x
|
||||
BenchmarkEncode/32-8 439.14 2690.43 6.13x
|
||||
BenchmarkEncode/128-8 441.54 5982.92 13.55x
|
||||
BenchmarkEncode/1k-8 451.49 11572.80 25.63x
|
||||
BenchmarkEncode/16k-8 418.91 13058.10 31.17x
|
||||
BenchmarkEncode/128k-8 450.02 10109.53 22.46x
|
||||
BenchmarkEncode/1M-8 460.39 8777.23 19.06x
|
||||
BenchmarkEncode/16M-8 452.37 4752.24 10.51x
|
||||
BenchmarkEncode/128M-8 457.13 4793.16 10.49x
|
||||
BenchmarkDecode/14-8 260.49 1110.01 4.26x
|
||||
BenchmarkDecode/32-8 248.44 2558.10 10.30x
|
||||
BenchmarkDecode/128-8 265.95 4697.66 17.66x
|
||||
BenchmarkDecode/1k-8 245.43 6093.43 24.83x
|
||||
BenchmarkDecode/16k-8 146.30 6442.09 44.03x
|
||||
BenchmarkDecode/128k-8 144.18 6444.24 44.70x
|
||||
BenchmarkDecode/1M-8 144.12 6381.57 44.28x
|
||||
BenchmarkDecode/16M-8 143.92 5412.31 37.61x
|
||||
BenchmarkDecode/128M-8 143.72 5397.68 37.56x
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Unless otherwise noted, the go-hex source files are distributed under the Modified BSD License
|
||||
found in the LICENSE file.
|
137
vendor/github.com/tmthrgd/go-hex/hex.go
generated
vendored
Normal file
137
vendor/github.com/tmthrgd/go-hex/hex.go
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
// Copyright 2016 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Modified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package hex is an efficient hexadecimal implementation for Golang.
|
||||
package hex
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var errLength = errors.New("go-hex: odd length hex string")
|
||||
|
||||
var (
|
||||
lower = []byte("0123456789abcdef")
|
||||
upper = []byte("0123456789ABCDEF")
|
||||
)
|
||||
|
||||
// InvalidByteError values describe errors resulting from an invalid byte in a hex string.
|
||||
type InvalidByteError byte
|
||||
|
||||
func (e InvalidByteError) Error() string {
|
||||
return fmt.Sprintf("go-hex: invalid byte: %#U", rune(e))
|
||||
}
|
||||
|
||||
// EncodedLen returns the length of an encoding of n source bytes.
|
||||
func EncodedLen(n int) int {
|
||||
return n * 2
|
||||
}
|
||||
|
||||
// DecodedLen returns the length of a decoding of n source bytes.
|
||||
func DecodedLen(n int) int {
|
||||
return n / 2
|
||||
}
|
||||
|
||||
// Encode encodes src into EncodedLen(len(src))
|
||||
// bytes of dst. As a convenience, it returns the number
|
||||
// of bytes written to dst, but this value is always EncodedLen(len(src)).
|
||||
// Encode implements lowercase hexadecimal encoding.
|
||||
func Encode(dst, src []byte) int {
|
||||
return RawEncode(dst, src, lower)
|
||||
}
|
||||
|
||||
// EncodeUpper encodes src into EncodedLen(len(src))
|
||||
// bytes of dst. As a convenience, it returns the number
|
||||
// of bytes written to dst, but this value is always EncodedLen(len(src)).
|
||||
// EncodeUpper implements uppercase hexadecimal encoding.
|
||||
func EncodeUpper(dst, src []byte) int {
|
||||
return RawEncode(dst, src, upper)
|
||||
}
|
||||
|
||||
// EncodeToString returns the lowercase hexadecimal encoding of src.
|
||||
func EncodeToString(src []byte) string {
|
||||
return RawEncodeToString(src, lower)
|
||||
}
|
||||
|
||||
// EncodeUpperToString returns the uppercase hexadecimal encoding of src.
|
||||
func EncodeUpperToString(src []byte) string {
|
||||
return RawEncodeToString(src, upper)
|
||||
}
|
||||
|
||||
// RawEncodeToString returns the hexadecimal encoding of src for a given
|
||||
// alphabet.
|
||||
func RawEncodeToString(src, alpha []byte) string {
|
||||
dst := make([]byte, EncodedLen(len(src)))
|
||||
RawEncode(dst, src, alpha)
|
||||
return string(dst)
|
||||
}
|
||||
|
||||
// DecodeString returns the bytes represented by the hexadecimal string s.
|
||||
func DecodeString(s string) ([]byte, error) {
|
||||
src := []byte(s)
|
||||
dst := make([]byte, DecodedLen(len(src)))
|
||||
|
||||
if _, err := Decode(dst, src); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
// MustDecodeString is like DecodeString but panics if the string cannot be
|
||||
// parsed. It simplifies safe initialization of global variables holding
|
||||
// binary data.
|
||||
func MustDecodeString(str string) []byte {
|
||||
dst, err := DecodeString(str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
func encodeGeneric(dst, src, alpha []byte) {
|
||||
for i, v := range src {
|
||||
dst[i*2] = alpha[v>>4]
|
||||
dst[i*2+1] = alpha[v&0x0f]
|
||||
}
|
||||
}
|
||||
|
||||
func decodeGeneric(dst, src []byte) (uint64, bool) {
|
||||
for i := 0; i < len(src)/2; i++ {
|
||||
a, ok := fromHexChar(src[i*2])
|
||||
if !ok {
|
||||
return uint64(i * 2), false
|
||||
}
|
||||
|
||||
b, ok := fromHexChar(src[i*2+1])
|
||||
if !ok {
|
||||
return uint64(i*2 + 1), false
|
||||
}
|
||||
|
||||
dst[i] = (a << 4) | b
|
||||
}
|
||||
|
||||
return 0, true
|
||||
}
|
||||
|
||||
// fromHexChar converts a hex character into its value and a success flag.
|
||||
func fromHexChar(c byte) (byte, bool) {
|
||||
switch {
|
||||
case '0' <= c && c <= '9':
|
||||
return c - '0', true
|
||||
case 'a' <= c && c <= 'f':
|
||||
return c - 'a' + 10, true
|
||||
case 'A' <= c && c <= 'F':
|
||||
return c - 'A' + 10, true
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
94
vendor/github.com/tmthrgd/go-hex/hex_amd64.go
generated
vendored
Normal file
94
vendor/github.com/tmthrgd/go-hex/hex_amd64.go
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright 2016 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Modified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
|
||||
// +build amd64,!gccgo,!appengine
|
||||
|
||||
package hex
|
||||
|
||||
import "golang.org/x/sys/cpu"
|
||||
|
||||
// RawEncode encodes src into EncodedLen(len(src))
|
||||
// bytes of dst. As a convenience, it returns the number
|
||||
// of bytes written to dst, but this value is always EncodedLen(len(src)).
|
||||
// RawEncode implements hexadecimal encoding for a given alphabet.
|
||||
func RawEncode(dst, src, alpha []byte) int {
|
||||
if len(alpha) != 16 {
|
||||
panic("invalid alphabet")
|
||||
}
|
||||
|
||||
if len(dst) < len(src)*2 {
|
||||
panic("dst buffer is too small")
|
||||
}
|
||||
|
||||
if len(src) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
switch {
|
||||
case cpu.X86.HasAVX:
|
||||
encodeAVX(&dst[0], &src[0], uint64(len(src)), &alpha[0])
|
||||
case cpu.X86.HasSSE41:
|
||||
encodeSSE(&dst[0], &src[0], uint64(len(src)), &alpha[0])
|
||||
default:
|
||||
encodeGeneric(dst, src, alpha)
|
||||
}
|
||||
|
||||
return len(src) * 2
|
||||
}
|
||||
|
||||
// Decode decodes src into DecodedLen(len(src)) bytes, returning the actual
|
||||
// number of bytes written to dst.
|
||||
//
|
||||
// If Decode encounters invalid input, it returns an error describing the failure.
|
||||
func Decode(dst, src []byte) (int, error) {
|
||||
if len(src)%2 != 0 {
|
||||
return 0, errLength
|
||||
}
|
||||
|
||||
if len(dst) < len(src)/2 {
|
||||
panic("dst buffer is too small")
|
||||
}
|
||||
|
||||
if len(src) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
var (
|
||||
n uint64
|
||||
ok bool
|
||||
)
|
||||
switch {
|
||||
case cpu.X86.HasAVX:
|
||||
n, ok = decodeAVX(&dst[0], &src[0], uint64(len(src)))
|
||||
case cpu.X86.HasSSE41:
|
||||
n, ok = decodeSSE(&dst[0], &src[0], uint64(len(src)))
|
||||
default:
|
||||
n, ok = decodeGeneric(dst, src)
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return 0, InvalidByteError(src[n])
|
||||
}
|
||||
|
||||
return len(src) / 2, nil
|
||||
}
|
||||
|
||||
//go:generate go run asm_gen.go
|
||||
|
||||
// This function is implemented in hex_encode_amd64.s
|
||||
//go:noescape
|
||||
func encodeAVX(dst *byte, src *byte, len uint64, alpha *byte)
|
||||
|
||||
// This function is implemented in hex_encode_amd64.s
|
||||
//go:noescape
|
||||
func encodeSSE(dst *byte, src *byte, len uint64, alpha *byte)
|
||||
|
||||
// This function is implemented in hex_decode_amd64.s
|
||||
//go:noescape
|
||||
func decodeAVX(dst *byte, src *byte, len uint64) (n uint64, ok bool)
|
||||
|
||||
// This function is implemented in hex_decode_amd64.s
|
||||
//go:noescape
|
||||
func decodeSSE(dst *byte, src *byte, len uint64) (n uint64, ok bool)
|
303
vendor/github.com/tmthrgd/go-hex/hex_decode_amd64.s
generated
vendored
Normal file
303
vendor/github.com/tmthrgd/go-hex/hex_decode_amd64.s
generated
vendored
Normal file
@ -0,0 +1,303 @@
|
||||
// Copyright 2016 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Modified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Copyright 2005-2016, Wojciech Muła. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Simplified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// This file is auto-generated - do not modify
|
||||
|
||||
// +build amd64,!gccgo,!appengine
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
DATA decodeBase<>+0x00(SB)/8, $0x3030303030303030
|
||||
DATA decodeBase<>+0x08(SB)/8, $0x3030303030303030
|
||||
DATA decodeBase<>+0x10(SB)/8, $0x2727272727272727
|
||||
DATA decodeBase<>+0x18(SB)/8, $0x2727272727272727
|
||||
GLOBL decodeBase<>(SB),RODATA,$32
|
||||
|
||||
DATA decodeToLower<>+0x00(SB)/8, $0x2020202020202020
|
||||
DATA decodeToLower<>+0x08(SB)/8, $0x2020202020202020
|
||||
GLOBL decodeToLower<>(SB),RODATA,$16
|
||||
|
||||
DATA decodeHigh<>+0x00(SB)/8, $0x0e0c0a0806040200
|
||||
DATA decodeHigh<>+0x08(SB)/8, $0xffffffffffffffff
|
||||
GLOBL decodeHigh<>(SB),RODATA,$16
|
||||
|
||||
DATA decodeLow<>+0x00(SB)/8, $0x0f0d0b0907050301
|
||||
DATA decodeLow<>+0x08(SB)/8, $0xffffffffffffffff
|
||||
GLOBL decodeLow<>(SB),RODATA,$16
|
||||
|
||||
DATA decodeValid<>+0x00(SB)/8, $0xb0b0b0b0b0b0b0b0
|
||||
DATA decodeValid<>+0x08(SB)/8, $0xb0b0b0b0b0b0b0b0
|
||||
DATA decodeValid<>+0x10(SB)/8, $0xb9b9b9b9b9b9b9b9
|
||||
DATA decodeValid<>+0x18(SB)/8, $0xb9b9b9b9b9b9b9b9
|
||||
DATA decodeValid<>+0x20(SB)/8, $0xe1e1e1e1e1e1e1e1
|
||||
DATA decodeValid<>+0x28(SB)/8, $0xe1e1e1e1e1e1e1e1
|
||||
DATA decodeValid<>+0x30(SB)/8, $0xe6e6e6e6e6e6e6e6
|
||||
DATA decodeValid<>+0x38(SB)/8, $0xe6e6e6e6e6e6e6e6
|
||||
GLOBL decodeValid<>(SB),RODATA,$64
|
||||
|
||||
DATA decodeToSigned<>+0x00(SB)/8, $0x8080808080808080
|
||||
DATA decodeToSigned<>+0x08(SB)/8, $0x8080808080808080
|
||||
GLOBL decodeToSigned<>(SB),RODATA,$16
|
||||
|
||||
TEXT ·decodeAVX(SB),NOSPLIT,$0
|
||||
MOVQ dst+0(FP), DI
|
||||
MOVQ src+8(FP), SI
|
||||
MOVQ len+16(FP), BX
|
||||
MOVQ SI, R15
|
||||
MOVOU decodeValid<>(SB), X14
|
||||
MOVOU decodeValid<>+0x20(SB), X15
|
||||
MOVW $65535, DX
|
||||
CMPQ BX, $16
|
||||
JB tail
|
||||
bigloop:
|
||||
MOVOU (SI), X0
|
||||
VPXOR decodeToSigned<>(SB), X0, X1
|
||||
POR decodeToLower<>(SB), X0
|
||||
VPXOR decodeToSigned<>(SB), X0, X2
|
||||
VPCMPGTB X1, X14, X3
|
||||
PCMPGTB decodeValid<>+0x10(SB), X1
|
||||
VPCMPGTB X2, X15, X4
|
||||
PCMPGTB decodeValid<>+0x30(SB), X2
|
||||
PAND X4, X1
|
||||
POR X2, X3
|
||||
POR X1, X3
|
||||
PMOVMSKB X3, AX
|
||||
TESTW AX, DX
|
||||
JNZ invalid
|
||||
PSUBB decodeBase<>(SB), X0
|
||||
PANDN decodeBase<>+0x10(SB), X4
|
||||
PSUBB X4, X0
|
||||
VPSHUFB decodeLow<>(SB), X0, X3
|
||||
PSHUFB decodeHigh<>(SB), X0
|
||||
PSLLW $4, X0
|
||||
POR X3, X0
|
||||
MOVQ X0, (DI)
|
||||
SUBQ $16, BX
|
||||
JZ ret
|
||||
ADDQ $16, SI
|
||||
ADDQ $8, DI
|
||||
CMPQ BX, $16
|
||||
JAE bigloop
|
||||
tail:
|
||||
MOVQ $16, CX
|
||||
SUBQ BX, CX
|
||||
SHRW CX, DX
|
||||
CMPQ BX, $4
|
||||
JB tail_in_2
|
||||
JE tail_in_4
|
||||
CMPQ BX, $8
|
||||
JB tail_in_6
|
||||
JE tail_in_8
|
||||
CMPQ BX, $12
|
||||
JB tail_in_10
|
||||
JE tail_in_12
|
||||
tail_in_14:
|
||||
PINSRW $6, 12(SI), X0
|
||||
tail_in_12:
|
||||
PINSRW $5, 10(SI), X0
|
||||
tail_in_10:
|
||||
PINSRW $4, 8(SI), X0
|
||||
tail_in_8:
|
||||
PINSRQ $0, (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_6:
|
||||
PINSRW $2, 4(SI), X0
|
||||
tail_in_4:
|
||||
PINSRW $1, 2(SI), X0
|
||||
tail_in_2:
|
||||
PINSRW $0, (SI), X0
|
||||
tail_conv:
|
||||
VPXOR decodeToSigned<>(SB), X0, X1
|
||||
POR decodeToLower<>(SB), X0
|
||||
VPXOR decodeToSigned<>(SB), X0, X2
|
||||
VPCMPGTB X1, X14, X3
|
||||
PCMPGTB decodeValid<>+0x10(SB), X1
|
||||
VPCMPGTB X2, X15, X4
|
||||
PCMPGTB decodeValid<>+0x30(SB), X2
|
||||
PAND X4, X1
|
||||
POR X2, X3
|
||||
POR X1, X3
|
||||
PMOVMSKB X3, AX
|
||||
TESTW AX, DX
|
||||
JNZ invalid
|
||||
PSUBB decodeBase<>(SB), X0
|
||||
PANDN decodeBase<>+0x10(SB), X4
|
||||
PSUBB X4, X0
|
||||
VPSHUFB decodeLow<>(SB), X0, X3
|
||||
PSHUFB decodeHigh<>(SB), X0
|
||||
PSLLW $4, X0
|
||||
POR X3, X0
|
||||
CMPQ BX, $4
|
||||
JB tail_out_2
|
||||
JE tail_out_4
|
||||
CMPQ BX, $8
|
||||
JB tail_out_6
|
||||
JE tail_out_8
|
||||
CMPQ BX, $12
|
||||
JB tail_out_10
|
||||
JE tail_out_12
|
||||
tail_out_14:
|
||||
PEXTRB $6, X0, 6(DI)
|
||||
tail_out_12:
|
||||
PEXTRB $5, X0, 5(DI)
|
||||
tail_out_10:
|
||||
PEXTRB $4, X0, 4(DI)
|
||||
tail_out_8:
|
||||
MOVL X0, (DI)
|
||||
JMP ret
|
||||
tail_out_6:
|
||||
PEXTRB $2, X0, 2(DI)
|
||||
tail_out_4:
|
||||
PEXTRB $1, X0, 1(DI)
|
||||
tail_out_2:
|
||||
PEXTRB $0, X0, (DI)
|
||||
ret:
|
||||
MOVB $1, ok+32(FP)
|
||||
RET
|
||||
invalid:
|
||||
BSFW AX, AX
|
||||
SUBQ R15, SI
|
||||
ADDQ SI, AX
|
||||
MOVQ AX, n+24(FP)
|
||||
MOVB $0, ok+32(FP)
|
||||
RET
|
||||
|
||||
TEXT ·decodeSSE(SB),NOSPLIT,$0
|
||||
MOVQ dst+0(FP), DI
|
||||
MOVQ src+8(FP), SI
|
||||
MOVQ len+16(FP), BX
|
||||
MOVQ SI, R15
|
||||
MOVOU decodeValid<>(SB), X14
|
||||
MOVOU decodeValid<>+0x20(SB), X15
|
||||
MOVW $65535, DX
|
||||
CMPQ BX, $16
|
||||
JB tail
|
||||
bigloop:
|
||||
MOVOU (SI), X0
|
||||
MOVOU X0, X1
|
||||
PXOR decodeToSigned<>(SB), X1
|
||||
POR decodeToLower<>(SB), X0
|
||||
MOVOU X0, X2
|
||||
PXOR decodeToSigned<>(SB), X2
|
||||
MOVOU X14, X3
|
||||
PCMPGTB X1, X3
|
||||
PCMPGTB decodeValid<>+0x10(SB), X1
|
||||
MOVOU X15, X4
|
||||
PCMPGTB X2, X4
|
||||
PCMPGTB decodeValid<>+0x30(SB), X2
|
||||
PAND X4, X1
|
||||
POR X2, X3
|
||||
POR X1, X3
|
||||
PMOVMSKB X3, AX
|
||||
TESTW AX, DX
|
||||
JNZ invalid
|
||||
PSUBB decodeBase<>(SB), X0
|
||||
PANDN decodeBase<>+0x10(SB), X4
|
||||
PSUBB X4, X0
|
||||
MOVOU X0, X3
|
||||
PSHUFB decodeLow<>(SB), X3
|
||||
PSHUFB decodeHigh<>(SB), X0
|
||||
PSLLW $4, X0
|
||||
POR X3, X0
|
||||
MOVQ X0, (DI)
|
||||
SUBQ $16, BX
|
||||
JZ ret
|
||||
ADDQ $16, SI
|
||||
ADDQ $8, DI
|
||||
CMPQ BX, $16
|
||||
JAE bigloop
|
||||
tail:
|
||||
MOVQ $16, CX
|
||||
SUBQ BX, CX
|
||||
SHRW CX, DX
|
||||
CMPQ BX, $4
|
||||
JB tail_in_2
|
||||
JE tail_in_4
|
||||
CMPQ BX, $8
|
||||
JB tail_in_6
|
||||
JE tail_in_8
|
||||
CMPQ BX, $12
|
||||
JB tail_in_10
|
||||
JE tail_in_12
|
||||
tail_in_14:
|
||||
PINSRW $6, 12(SI), X0
|
||||
tail_in_12:
|
||||
PINSRW $5, 10(SI), X0
|
||||
tail_in_10:
|
||||
PINSRW $4, 8(SI), X0
|
||||
tail_in_8:
|
||||
PINSRQ $0, (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_6:
|
||||
PINSRW $2, 4(SI), X0
|
||||
tail_in_4:
|
||||
PINSRW $1, 2(SI), X0
|
||||
tail_in_2:
|
||||
PINSRW $0, (SI), X0
|
||||
tail_conv:
|
||||
MOVOU X0, X1
|
||||
PXOR decodeToSigned<>(SB), X1
|
||||
POR decodeToLower<>(SB), X0
|
||||
MOVOU X0, X2
|
||||
PXOR decodeToSigned<>(SB), X2
|
||||
MOVOU X14, X3
|
||||
PCMPGTB X1, X3
|
||||
PCMPGTB decodeValid<>+0x10(SB), X1
|
||||
MOVOU X15, X4
|
||||
PCMPGTB X2, X4
|
||||
PCMPGTB decodeValid<>+0x30(SB), X2
|
||||
PAND X4, X1
|
||||
POR X2, X3
|
||||
POR X1, X3
|
||||
PMOVMSKB X3, AX
|
||||
TESTW AX, DX
|
||||
JNZ invalid
|
||||
PSUBB decodeBase<>(SB), X0
|
||||
PANDN decodeBase<>+0x10(SB), X4
|
||||
PSUBB X4, X0
|
||||
MOVOU X0, X3
|
||||
PSHUFB decodeLow<>(SB), X3
|
||||
PSHUFB decodeHigh<>(SB), X0
|
||||
PSLLW $4, X0
|
||||
POR X3, X0
|
||||
CMPQ BX, $4
|
||||
JB tail_out_2
|
||||
JE tail_out_4
|
||||
CMPQ BX, $8
|
||||
JB tail_out_6
|
||||
JE tail_out_8
|
||||
CMPQ BX, $12
|
||||
JB tail_out_10
|
||||
JE tail_out_12
|
||||
tail_out_14:
|
||||
PEXTRB $6, X0, 6(DI)
|
||||
tail_out_12:
|
||||
PEXTRB $5, X0, 5(DI)
|
||||
tail_out_10:
|
||||
PEXTRB $4, X0, 4(DI)
|
||||
tail_out_8:
|
||||
MOVL X0, (DI)
|
||||
JMP ret
|
||||
tail_out_6:
|
||||
PEXTRB $2, X0, 2(DI)
|
||||
tail_out_4:
|
||||
PEXTRB $1, X0, 1(DI)
|
||||
tail_out_2:
|
||||
PEXTRB $0, X0, (DI)
|
||||
ret:
|
||||
MOVB $1, ok+32(FP)
|
||||
RET
|
||||
invalid:
|
||||
BSFW AX, AX
|
||||
SUBQ R15, SI
|
||||
ADDQ SI, AX
|
||||
MOVQ AX, n+24(FP)
|
||||
MOVB $0, ok+32(FP)
|
||||
RET
|
227
vendor/github.com/tmthrgd/go-hex/hex_encode_amd64.s
generated
vendored
Normal file
227
vendor/github.com/tmthrgd/go-hex/hex_encode_amd64.s
generated
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
// Copyright 2016 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Modified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// Copyright 2005-2016, Wojciech Muła. All rights reserved.
|
||||
// Use of this source code is governed by a
|
||||
// Simplified BSD License license that can be found in
|
||||
// the LICENSE file.
|
||||
//
|
||||
// This file is auto-generated - do not modify
|
||||
|
||||
// +build amd64,!gccgo,!appengine
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
DATA encodeMask<>+0x00(SB)/8, $0x0f0f0f0f0f0f0f0f
|
||||
DATA encodeMask<>+0x08(SB)/8, $0x0f0f0f0f0f0f0f0f
|
||||
GLOBL encodeMask<>(SB),RODATA,$16
|
||||
|
||||
TEXT ·encodeAVX(SB),NOSPLIT,$0
|
||||
MOVQ dst+0(FP), DI
|
||||
MOVQ src+8(FP), SI
|
||||
MOVQ len+16(FP), BX
|
||||
MOVQ alpha+24(FP), DX
|
||||
MOVOU (DX), X15
|
||||
CMPQ BX, $16
|
||||
JB tail
|
||||
bigloop:
|
||||
MOVOU -16(SI)(BX*1), X0
|
||||
VPAND encodeMask<>(SB), X0, X1
|
||||
PSRLW $4, X0
|
||||
PAND encodeMask<>(SB), X0
|
||||
VPUNPCKHBW X1, X0, X3
|
||||
PUNPCKLBW X1, X0
|
||||
VPSHUFB X0, X15, X1
|
||||
VPSHUFB X3, X15, X2
|
||||
MOVOU X2, -16(DI)(BX*2)
|
||||
MOVOU X1, -32(DI)(BX*2)
|
||||
SUBQ $16, BX
|
||||
JZ ret
|
||||
CMPQ BX, $16
|
||||
JAE bigloop
|
||||
tail:
|
||||
CMPQ BX, $2
|
||||
JB tail_in_1
|
||||
JE tail_in_2
|
||||
CMPQ BX, $4
|
||||
JB tail_in_3
|
||||
JE tail_in_4
|
||||
CMPQ BX, $6
|
||||
JB tail_in_5
|
||||
JE tail_in_6
|
||||
CMPQ BX, $8
|
||||
JB tail_in_7
|
||||
tail_in_8:
|
||||
MOVQ (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_7:
|
||||
PINSRB $6, 6(SI), X0
|
||||
tail_in_6:
|
||||
PINSRB $5, 5(SI), X0
|
||||
tail_in_5:
|
||||
PINSRB $4, 4(SI), X0
|
||||
tail_in_4:
|
||||
PINSRD $0, (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_3:
|
||||
PINSRB $2, 2(SI), X0
|
||||
tail_in_2:
|
||||
PINSRB $1, 1(SI), X0
|
||||
tail_in_1:
|
||||
PINSRB $0, (SI), X0
|
||||
tail_conv:
|
||||
VPAND encodeMask<>(SB), X0, X1
|
||||
PSRLW $4, X0
|
||||
PAND encodeMask<>(SB), X0
|
||||
PUNPCKLBW X1, X0
|
||||
VPSHUFB X0, X15, X1
|
||||
CMPQ BX, $2
|
||||
JB tail_out_1
|
||||
JE tail_out_2
|
||||
CMPQ BX, $4
|
||||
JB tail_out_3
|
||||
JE tail_out_4
|
||||
CMPQ BX, $6
|
||||
JB tail_out_5
|
||||
JE tail_out_6
|
||||
CMPQ BX, $8
|
||||
JB tail_out_7
|
||||
tail_out_8:
|
||||
MOVOU X1, (DI)
|
||||
SUBQ $8, BX
|
||||
JZ ret
|
||||
ADDQ $8, SI
|
||||
ADDQ $16, DI
|
||||
JMP tail
|
||||
tail_out_7:
|
||||
PEXTRB $13, X1, 13(DI)
|
||||
PEXTRB $12, X1, 12(DI)
|
||||
tail_out_6:
|
||||
PEXTRB $11, X1, 11(DI)
|
||||
PEXTRB $10, X1, 10(DI)
|
||||
tail_out_5:
|
||||
PEXTRB $9, X1, 9(DI)
|
||||
PEXTRB $8, X1, 8(DI)
|
||||
tail_out_4:
|
||||
MOVQ X1, (DI)
|
||||
RET
|
||||
tail_out_3:
|
||||
PEXTRB $5, X1, 5(DI)
|
||||
PEXTRB $4, X1, 4(DI)
|
||||
tail_out_2:
|
||||
PEXTRB $3, X1, 3(DI)
|
||||
PEXTRB $2, X1, 2(DI)
|
||||
tail_out_1:
|
||||
PEXTRB $1, X1, 1(DI)
|
||||
PEXTRB $0, X1, (DI)
|
||||
ret:
|
||||
RET
|
||||
|
||||
TEXT ·encodeSSE(SB),NOSPLIT,$0
|
||||
MOVQ dst+0(FP), DI
|
||||
MOVQ src+8(FP), SI
|
||||
MOVQ len+16(FP), BX
|
||||
MOVQ alpha+24(FP), DX
|
||||
MOVOU (DX), X15
|
||||
CMPQ BX, $16
|
||||
JB tail
|
||||
bigloop:
|
||||
MOVOU -16(SI)(BX*1), X0
|
||||
MOVOU X0, X1
|
||||
PAND encodeMask<>(SB), X1
|
||||
PSRLW $4, X0
|
||||
PAND encodeMask<>(SB), X0
|
||||
MOVOU X0, X3
|
||||
PUNPCKHBW X1, X3
|
||||
PUNPCKLBW X1, X0
|
||||
MOVOU X15, X1
|
||||
PSHUFB X0, X1
|
||||
MOVOU X15, X2
|
||||
PSHUFB X3, X2
|
||||
MOVOU X2, -16(DI)(BX*2)
|
||||
MOVOU X1, -32(DI)(BX*2)
|
||||
SUBQ $16, BX
|
||||
JZ ret
|
||||
CMPQ BX, $16
|
||||
JAE bigloop
|
||||
tail:
|
||||
CMPQ BX, $2
|
||||
JB tail_in_1
|
||||
JE tail_in_2
|
||||
CMPQ BX, $4
|
||||
JB tail_in_3
|
||||
JE tail_in_4
|
||||
CMPQ BX, $6
|
||||
JB tail_in_5
|
||||
JE tail_in_6
|
||||
CMPQ BX, $8
|
||||
JB tail_in_7
|
||||
tail_in_8:
|
||||
MOVQ (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_7:
|
||||
PINSRB $6, 6(SI), X0
|
||||
tail_in_6:
|
||||
PINSRB $5, 5(SI), X0
|
||||
tail_in_5:
|
||||
PINSRB $4, 4(SI), X0
|
||||
tail_in_4:
|
||||
PINSRD $0, (SI), X0
|
||||
JMP tail_conv
|
||||
tail_in_3:
|
||||
PINSRB $2, 2(SI), X0
|
||||
tail_in_2:
|
||||
PINSRB $1, 1(SI), X0
|
||||
tail_in_1:
|
||||
PINSRB $0, (SI), X0
|
||||
tail_conv:
|
||||
MOVOU X0, X1
|
||||
PAND encodeMask<>(SB), X1
|
||||
PSRLW $4, X0
|
||||
PAND encodeMask<>(SB), X0
|
||||
PUNPCKLBW X1, X0
|
||||
MOVOU X15, X1
|
||||
PSHUFB X0, X1
|
||||
CMPQ BX, $2
|
||||
JB tail_out_1
|
||||
JE tail_out_2
|
||||
CMPQ BX, $4
|
||||
JB tail_out_3
|
||||
JE tail_out_4
|
||||
CMPQ BX, $6
|
||||
JB tail_out_5
|
||||
JE tail_out_6
|
||||
CMPQ BX, $8
|
||||
JB tail_out_7
|
||||
tail_out_8:
|
||||
MOVOU X1, (DI)
|
||||
SUBQ $8, BX
|
||||
JZ ret
|
||||
ADDQ $8, SI
|
||||
ADDQ $16, DI
|
||||
JMP tail
|
||||
tail_out_7:
|
||||
PEXTRB $13, X1, 13(DI)
|
||||
PEXTRB $12, X1, 12(DI)
|
||||
tail_out_6:
|
||||
PEXTRB $11, X1, 11(DI)
|
||||
PEXTRB $10, X1, 10(DI)
|
||||
tail_out_5:
|
||||
PEXTRB $9, X1, 9(DI)
|
||||
PEXTRB $8, X1, 8(DI)
|
||||
tail_out_4:
|
||||
MOVQ X1, (DI)
|
||||
RET
|
||||
tail_out_3:
|
||||
PEXTRB $5, X1, 5(DI)
|
||||
PEXTRB $4, X1, 4(DI)
|
||||
tail_out_2:
|
||||
PEXTRB $3, X1, 3(DI)
|
||||
PEXTRB $2, X1, 2(DI)
|
||||
tail_out_1:
|
||||
PEXTRB $1, X1, 1(DI)
|
||||
PEXTRB $0, X1, (DI)
|
||||
ret:
|
||||
RET
|
36
vendor/github.com/tmthrgd/go-hex/hex_other.go
generated
vendored
Normal file
36
vendor/github.com/tmthrgd/go-hex/hex_other.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !amd64 gccgo appengine
|
||||
|
||||
package hex
|
||||
|
||||
// RawEncode encodes src into EncodedLen(len(src))
|
||||
// bytes of dst. As a convenience, it returns the number
|
||||
// of bytes written to dst, but this value is always EncodedLen(len(src)).
|
||||
// RawEncode implements hexadecimal encoding for a given alphabet.
|
||||
func RawEncode(dst, src, alpha []byte) int {
|
||||
if len(alpha) != 16 {
|
||||
panic("invalid alphabet")
|
||||
}
|
||||
|
||||
encodeGeneric(dst, src, alpha)
|
||||
return len(src) * 2
|
||||
}
|
||||
|
||||
// Decode decodes src into DecodedLen(len(src)) bytes, returning the actual
|
||||
// number of bytes written to dst.
|
||||
//
|
||||
// If Decode encounters invalid input, it returns an error describing the failure.
|
||||
func Decode(dst, src []byte) (int, error) {
|
||||
if len(src)%2 == 1 {
|
||||
return 0, errLength
|
||||
}
|
||||
|
||||
if n, ok := decodeGeneric(dst, src); !ok {
|
||||
return 0, InvalidByteError(src[n])
|
||||
}
|
||||
|
||||
return len(src) / 2, nil
|
||||
}
|
Reference in New Issue
Block a user