You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/types/prefs
Nick Khyl da9965d51c cmd/viewer,types/views,various: avoid allocations in pointer field getters whenever possible
In this PR, we add a generic views.ValuePointer type that can be used as a view for pointers
to basic types and struct types that do not require deep cloning and do not have corresponding
view types. Its Get/GetOk methods return stack-allocated shallow copies of the underlying value.

We then update the cmd/viewer codegen to produce getters that return either concrete views
when available or ValuePointer views when not, for pointer fields in generated view types.
This allows us to avoid unnecessary allocations compared to returning pointers to newly
allocated shallow copies.

Updates #14570

Signed-off-by: Nick Khyl <nickk@tailscale.com>
11 months ago
..
prefs_example types/prefs: add a package containing generic preference types 1 year ago
item.go types/prefs: add a package containing generic preference types 1 year ago
list.go types/prefs: add a package containing generic preference types 1 year ago
map.go types/prefs: add a package containing generic preference types 1 year ago
options.go types/prefs: add a package containing generic preference types 1 year ago
prefs.go types/prefs: add a package containing generic preference types 1 year ago
prefs_clone_test.go types/prefs: add a package containing generic preference types 1 year ago
prefs_test.go types/prefs: add a package containing generic preference types 1 year ago
prefs_view_test.go cmd/viewer,types/views,various: avoid allocations in pointer field getters whenever possible 11 months ago
struct_list.go types/prefs: add a package containing generic preference types 1 year ago
struct_map.go types/prefs: add a package containing generic preference types 1 year ago