diff options
| author | 2025-08-21 16:41:50 +0200 | |
|---|---|---|
| committer | 2025-08-21 16:41:50 +0200 | |
| commit | a79f83cbded3fb1165b338ce316dc9f2217467ff (patch) | |
| tree | 4b4a2b7084aced51c0a691cee6352b4ecae90df8 /vendor/codeberg.org/gruf/go-mangler/v2/manglers.go | |
| parent | [chore] bump golangci-lint version in CI, disable var-naming package name che... (diff) | |
| download | gotosocial-a79f83cbded3fb1165b338ce316dc9f2217467ff.tar.xz | |
[chore] update dependencies (#4386)
- codeberg.org/gruf/go-bytesize v1.0.3 -> v1.0.4
- codeberg.org/gruf/go-kv/v2 v2.0.6 -> v2.0.7
- codeberg.org/gruf/go-mutexes v1.5.2 -> v1.5.3
- codeberg.org/gruf/go-structr v0.9.7 -> v0.9.8
- codeberg.org/gruf/go-ffmpreg v0.6.8 -> v0.6.9
- github.com/tomnomnom/linkheader HEAD@2018 -> HEAD@2025
all of the above codeberg.org/gruf updates are in preparation for Go1.25, except for bytesize, and also ffmpreg which is a rebuild with the latest version of ffmpeg (v5.1.7)
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4386
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mangler/v2/manglers.go')
| -rw-r--r-- | vendor/codeberg.org/gruf/go-mangler/v2/manglers.go | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go b/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go new file mode 100644 index 000000000..79bfe3c00 --- /dev/null +++ b/vendor/codeberg.org/gruf/go-mangler/v2/manglers.go @@ -0,0 +1,113 @@ +package mangler + +import ( + "unsafe" + _ "unsafe" +) + +// Notes: +// the use of unsafe conversion from the direct interface values to +// the chosen types in each of the below functions allows us to convert +// not only those types directly, but anything type-aliased to those +// types. e.g. `time.Duration` directly as int64. + +func mangle_string(buf []byte, ptr unsafe.Pointer) []byte { + return append(buf, *(*string)(ptr)...) +} + +func mangle_string_slice(buf []byte, ptr unsafe.Pointer) []byte { + s := *(*[]string)(ptr) + for _, s := range s { + buf = append(buf, s...) + buf = append(buf, ',') + } + if len(s) > 0 { + buf = buf[:len(buf)-1] + } + return buf +} + +func mangle_bool(buf []byte, ptr unsafe.Pointer) []byte { + if *(*bool)(ptr) { + return append(buf, '1') + } + return append(buf, '0') +} + +func mangle_bool_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, b := range *(*[]bool)(ptr) { + if b { + buf = append(buf, '1') + } else { + buf = append(buf, '0') + } + } + return buf +} + +func mangle_8bit(buf []byte, ptr unsafe.Pointer) []byte { + return append(buf, *(*uint8)(ptr)) +} + +func mangle_8bit_slice(buf []byte, ptr unsafe.Pointer) []byte { + return append(buf, *(*[]uint8)(ptr)...) +} + +func mangle_16bit(buf []byte, ptr unsafe.Pointer) []byte { + return append_uint16(buf, *(*uint16)(ptr)) +} + +func mangle_16bit_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, u := range *(*[]uint16)(ptr) { + buf = append_uint16(buf, u) + } + return buf +} + +func mangle_32bit(buf []byte, ptr unsafe.Pointer) []byte { + return append_uint32(buf, *(*uint32)(ptr)) +} + +func mangle_32bit_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, u := range *(*[]uint32)(ptr) { + buf = append_uint32(buf, u) + } + return buf +} + +func mangle_64bit(buf []byte, ptr unsafe.Pointer) []byte { + return append_uint64(buf, *(*uint64)(ptr)) +} + +func mangle_64bit_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, u := range *(*[]uint64)(ptr) { + buf = append_uint64(buf, u) + } + return buf +} + +func mangle_int(buf []byte, ptr unsafe.Pointer) []byte { + return append_uint64(buf, uint64(*(*uint)(ptr))) +} + +func mangle_int_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, u := range *(*[]uint)(ptr) { + buf = append_uint64(buf, uint64(u)) + } + return buf +} + +func mangle_128bit(buf []byte, ptr unsafe.Pointer) []byte { + u2 := *(*[2]uint64)(ptr) + buf = append_uint64(buf, u2[0]) + buf = append_uint64(buf, u2[1]) + return buf +} + +func mangle_128bit_slice(buf []byte, ptr unsafe.Pointer) []byte { + for _, u2 := range *(*[][2]uint64)(ptr) { + buf = append_uint64(buf, u2[0]) + buf = append_uint64(buf, u2[1]) + } + return buf +} |
