summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-08-10 15:05:54 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-08-10 15:05:54 +0200
commit67100809b399b60e58490fa8b1c0a72be75ac820 (patch)
treeae6df939bf9fe557a766120bee3363f89b47f961 /vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
parent[feature + performance] add JSON logging format (#4355) (diff)
downloadgotosocial-67100809b399b60e58490fa8b1c0a72be75ac820.tar.xz
[chore] update dependencies (#4361)
- codeberg.org/gruf/go-kv/v2 v2.0.5 => v2.0.6 - github.com/coreos/go-oidc/v3 v3.14.1 => v3.15.0 - github.com/miekg/dns v1.1.67 => v1.1.68 - github.com/tdewolff/minify/v2 v2.23.9 => v2.23.11 - github.com/yuin/goldmark v1.7.12 => v1.7.13 - golang.org/x/crypto v0.40.0 => v0.41.0 - golang.org/x/image v0.29.0 => v0.30.0 - golang.org/x/net v0.42.0 => v0.43.0 - golang.org/x/sys v0.34.0 => v0.35.0 - golang.org/x/text v0.27.0 => v0.28.0 - modernc.org/sqlite v1.38.0 => v1.38.2 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4361 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-kv/v2/format/slice.go')
-rw-r--r--vendor/codeberg.org/gruf/go-kv/v2/format/slice.go36
1 files changed, 19 insertions, 17 deletions
diff --git a/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go b/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
index f76e85410..e53fc5c4b 100644
--- a/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
+++ b/vendor/codeberg.org/gruf/go-kv/v2/format/slice.go
@@ -1,18 +1,20 @@
package format
+import "codeberg.org/gruf/go-xunsafe"
+
// iterSliceType returns a FormatFunc capable of iterating
-// and formatting the given slice type currently in typenode{}.
+// and formatting the given slice type currently in TypeIter{}.
// note this will fetch a sub-FormatFunc for the slice element
// type, and also handle special cases of []byte, []rune slices.
-func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
+func (fmt *Formatter) iterSliceType(t xunsafe.TypeIter) FormatFunc {
// Get nested element type.
- elem := t.rtype.Elem()
+ elem := t.Type.Elem()
esz := elem.Size()
- // Get nested elem typenode with flags.
- flags := reflect_slice_elem_flags(elem)
- et := t.next(elem, flags)
+ // Get nested elem TypeIter{} with flags.
+ flags := xunsafe.ReflectSliceElemFlags(elem)
+ et := t.Child(elem, flags)
// Get elem format func.
fn := fmt.loadOrGet(et)
@@ -20,12 +22,12 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
panic("unreachable")
}
- if !t.needs_typestr() {
+ if !needs_typestr(t) {
return func(s *State) {
ptr := s.P
// Get data as unsafe slice header.
- hdr := (*unsafeheader_Slice)(ptr)
+ hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
if hdr == nil || hdr.Data == nil {
// Append nil.
@@ -57,14 +59,14 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
}
// Slice type string with ptrs / refs.
- typestrPtrs := t.typestr_with_ptrs()
- typestrRefs := t.typestr_with_refs()
+ typestrPtrs := typestr_with_ptrs(t)
+ typestrRefs := typestr_with_refs(t)
return func(s *State) {
ptr := s.P
// Get data as unsafe slice header.
- hdr := (*unsafeheader_Slice)(ptr)
+ hdr := (*xunsafe.Unsafeheader_Slice)(ptr)
if hdr == nil || hdr.Data == nil {
// Append nil value with type.
@@ -105,8 +107,8 @@ func (fmt *Formatter) iterSliceType(t typenode) FormatFunc {
}
}
-func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
- if !t.needs_typestr() {
+func wrapByteSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
+ if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
appendString(s, *(*string)(s.P))
@@ -115,7 +117,7 @@ func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
}
- typestr := t.typestr_with_ptrs()
+ typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
if s.A.WithType() {
@@ -131,8 +133,8 @@ func wrapByteSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
-func wrapRuneSlice(t typenode, fn FormatFunc) FormatFunc {
- if !t.needs_typestr() {
+func wrapRuneSlice(t xunsafe.TypeIter, fn FormatFunc) FormatFunc {
+ if !needs_typestr(t) {
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
appendString(s, string(*(*[]rune)(s.P)))
@@ -141,7 +143,7 @@ func wrapRuneSlice(t typenode, fn FormatFunc) FormatFunc {
}
}
}
- typestr := t.typestr_with_ptrs()
+ typestr := typestr_with_ptrs(t)
return func(s *State) {
if s.A.AsText() || s.A.AsQuotedText() || s.A.AsQuotedASCII() {
if s.A.WithType() {