diff options
author | 2025-03-09 17:47:56 +0100 | |
---|---|---|
committer | 2025-03-10 01:59:49 +0100 | |
commit | 3ac1ee16f377d31a0fb80c8dae28b6239ac4229e (patch) | |
tree | f61faa581feaaeaba2542b9f2b8234a590684413 /vendor/codeberg.org/gruf/go-byteutil | |
parent | [chore] update URLs to forked source (diff) | |
download | gotosocial-3ac1ee16f377d31a0fb80c8dae28b6239ac4229e.tar.xz |
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-byteutil')
-rw-r--r-- | vendor/codeberg.org/gruf/go-byteutil/LICENSE | 9 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-byteutil/README.md | 3 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-byteutil/buffer.go | 174 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-byteutil/bytes.go | 27 |
4 files changed, 0 insertions, 213 deletions
diff --git a/vendor/codeberg.org/gruf/go-byteutil/LICENSE b/vendor/codeberg.org/gruf/go-byteutil/LICENSE deleted file mode 100644 index d6f08d0ab..000000000 --- a/vendor/codeberg.org/gruf/go-byteutil/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) gruf - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/codeberg.org/gruf/go-byteutil/README.md b/vendor/codeberg.org/gruf/go-byteutil/README.md deleted file mode 100644 index e1f81d969..000000000 --- a/vendor/codeberg.org/gruf/go-byteutil/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# go-byteutil - -A useful package of byte utilities.
\ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-byteutil/buffer.go b/vendor/codeberg.org/gruf/go-byteutil/buffer.go deleted file mode 100644 index 8259429d6..000000000 --- a/vendor/codeberg.org/gruf/go-byteutil/buffer.go +++ /dev/null @@ -1,174 +0,0 @@ -package byteutil - -import ( - "errors" - "io" - "unicode/utf8" -) - -var ( - // ensure we conform - // to interfaces. - _ interface { - io.Writer - io.ByteWriter - WriteRune(rune) (int, error) - io.StringWriter - io.WriterAt - WriteStringAt(string, int64) (int, error) - io.ReaderFrom - io.WriterTo - } = (*Buffer)(nil) - - // ErrBeyondBufferLen is returned if .WriteAt() is attempted beyond buffer length. - ErrBeyondBufferLen = errors.New("start beyond buffer length") -) - -// Buffer is a simple wrapper around a byte slice. -type Buffer struct{ B []byte } - -// WriteByte will append given byte to buffer, fulfilling io.ByteWriter. -func (buf *Buffer) WriteByte(c byte) error { - buf.B = append(buf.B, c) - return nil -} - -// WriteRune will append given rune to buffer. -func (buf *Buffer) WriteRune(r rune) (int, error) { - // Check for single-byte rune - if r < utf8.RuneSelf { - buf.B = append(buf.B, byte(r)) - return 1, nil - } - - // Before-len - l := len(buf.B) - - // Grow to max size rune - buf.Grow(utf8.UTFMax) - - // Write encoded rune to buffer - n := utf8.EncodeRune(buf.B[l:len(buf.B)], r) - buf.B = buf.B[:l+n] - - return n, nil -} - -// Write will append given byte slice to buffer, fulfilling io.Writer. -func (buf *Buffer) Write(b []byte) (int, error) { - buf.B = append(buf.B, b...) - return len(b), nil -} - -// WriteString will append given string to buffer, fulfilling io.StringWriter. -func (buf *Buffer) WriteString(s string) (int, error) { - buf.B = append(buf.B, s...) - return len(s), nil -} - -// WriteAt will append given byte slice to buffer at index 'start', fulfilling io.WriterAt. -func (buf *Buffer) WriteAt(b []byte, start int64) (int, error) { - if start > int64(len(buf.B)) { - return 0, ErrBeyondBufferLen - } - buf.Grow(len(b) - int(int64(len(buf.B))-start)) - return copy(buf.B[start:], b), nil -} - -// WriteStringAt will append given string to buffer at index 'start'. -func (buf *Buffer) WriteStringAt(s string, start int64) (int, error) { - if start > int64(len(buf.B)) { - return 0, ErrBeyondBufferLen - } - buf.Grow(len(s) - int(int64(len(buf.B))-start)) - return copy(buf.B[start:], s), nil -} - -// ReadFrom will read bytes from reader into buffer, fulfilling io.ReaderFrom. -func (buf *Buffer) ReadFrom(r io.Reader) (int64, error) { - var nn int64 - - // Ensure there's cap - // for a first read. - buf.Guarantee(512) - - for { - // Read into next chunk of buffer. - n, err := r.Read(buf.B[len(buf.B):cap(buf.B)]) - - // Reslice buf + update count. - buf.B = buf.B[:len(buf.B)+n] - nn += int64(n) - - if err != nil { - if err == io.EOF { - // mask EOF. - err = nil - } - return nn, err - } - - if len(buf.B) == cap(buf.B) { - // Add capacity (let append pick). - buf.B = append(buf.B, 0)[:len(buf.B)] - } - } -} - -// WriteTo will write bytes from buffer into writer, fulfilling io.WriterTo. -func (buf *Buffer) WriteTo(w io.Writer) (int64, error) { - n, err := w.Write(buf.B) - return int64(n), err -} - -// Len returns the length of the buffer's underlying byte slice. -func (buf *Buffer) Len() int { - return len(buf.B) -} - -// Cap returns the capacity of the buffer's underlying byte slice. -func (buf *Buffer) Cap() int { - return cap(buf.B) -} - -// Grow will increase the buffers length by 'sz', and the capacity by at least this. -func (buf *Buffer) Grow(sz int) { - buf.Guarantee(sz) - buf.B = buf.B[:len(buf.B)+sz] -} - -// Guarantee will guarantee buffer containers at least 'sz' remaining capacity. -func (buf *Buffer) Guarantee(sz int) { - if sz > cap(buf.B)-len(buf.B) { - nb := make([]byte, 2*cap(buf.B)+sz) - copy(nb, buf.B) - buf.B = nb[:len(buf.B)] - } -} - -// Truncate will reduce the length of the buffer by 'n'. -func (buf *Buffer) Truncate(n int) { - if n > len(buf.B) { - n = len(buf.B) - } - buf.B = buf.B[:len(buf.B)-n] -} - -// Reset will reset the buffer length to 0 (retains capacity). -func (buf *Buffer) Reset() { - buf.B = buf.B[:0] -} - -// String returns the underlying byte slice as a string. Please note -// this value is tied directly to the underlying byte slice, if you -// write to the buffer then returned string values will also change. -// -// To get an immutable string from buffered data, use string(buf.B). -func (buf *Buffer) String() string { - return B2S(buf.B) -} - -// Full returns the full capacity byteslice allocated for this buffer. -func (buf *Buffer) Full() []byte { - return buf.B[0:cap(buf.B)] -} diff --git a/vendor/codeberg.org/gruf/go-byteutil/bytes.go b/vendor/codeberg.org/gruf/go-byteutil/bytes.go deleted file mode 100644 index 880cb4b6d..000000000 --- a/vendor/codeberg.org/gruf/go-byteutil/bytes.go +++ /dev/null @@ -1,27 +0,0 @@ -package byteutil - -import ( - "unsafe" -) - -// Copy returns a copy of []byte. -func Copy(b []byte) []byte { - if b == nil { - return nil - } - p := make([]byte, len(b)) - copy(p, b) - return p -} - -// B2S returns a string representation of []byte without allocation. -// Since Go strings are immutable, the bytes passed to String must -// not be modified as long as the returned string value exists. -func B2S(b []byte) string { - return unsafe.String(unsafe.SliceData(b), len(b)) -} - -// S2B returns a []byte representation of string without allocation. -func S2B(s string) []byte { - return unsafe.Slice(unsafe.StringData(s), len(s)) -} |