Skip to content

Commit

Permalink
Remove nullable option
Browse files Browse the repository at this point in the history
There is no longer the need to serialize null pointers
  • Loading branch information
nytzuga committed Dec 13, 2023
1 parent 1461137 commit f503086
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 209 deletions.
15 changes: 1 addition & 14 deletions codec/reflectcodec/struct_fielder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ const (

// TagValue is the value the tag must have to be serialized.
TagValue = "true"

// TagValue is the value the tag must have to be serialized, this variant
// includes the nullable option
TagWithNullableValue = "true,nullable"
)

var _ StructFielder = (*structFielder)(nil)

type FieldDesc struct {
Index int
MaxSliceLen uint32
Nullable bool
}

// StructFielder handles discovery of serializable fields in a struct.
Expand Down Expand Up @@ -89,17 +84,10 @@ func (s *structFielder) GetSerializedFields(t reflect.Type) ([]FieldDesc, error)
// any tag with the right value
var (
captureField bool
nullable bool
)
for _, tag := range s.tags {
switch field.Tag.Get(tag) {
case TagValue:
captureField = true
case TagWithNullableValue:
if field.Tag.Get(tag) == TagValue {
captureField = true
nullable = true
}
if captureField {
break
}
}
Expand All @@ -121,7 +109,6 @@ func (s *structFielder) GetSerializedFields(t reflect.Type) ([]FieldDesc, error)
serializedFields = append(serializedFields, FieldDesc{
Index: i,
MaxSliceLen: maxSliceLen,
Nullable: nullable,
})
}
s.serializedFieldIndices[t] = serializedFields // cache result
Expand Down
Loading

0 comments on commit f503086

Please sign in to comment.