MCPcopy Create free account
hub / github.com/google/gapid / unpackMapWithAllocator

Function unpackMapWithAllocator

gapis/api/vulkan/command_buffer_rebuilder.go:30–46  ·  view source on GitHub ↗

unpackMapWithAllocator takes a dense map of u32 -> structure, flattens the map into a slice, allocates the appropriate data using a custom provided allocation function and returns it as well as the length of the map.

(alloc func(v ...interface{}) api.AllocResult, m interface{})

Source from the content-addressed store, hash-verified

28// map into a slice, allocates the appropriate data using a custom provided
29// allocation function and returns it as well as the length of the map.
30func unpackMapWithAllocator(alloc func(v ...interface{}) api.AllocResult, m interface{}) (api.AllocResult, uint32) {
31 u32Type := reflect.TypeOf(uint32(0))
32 d := dictionary.From(m)
33 if d == nil || d.KeyTy() != u32Type {
34 msg := fmt.Sprintf("Expecting a map of u32 -> structures: got %T", m)
35 panic(msg)
36 }
37
38 sl := reflect.MakeSlice(reflect.SliceOf(d.ValTy()), d.Len(), d.Len())
39 for _, e := range dictionary.Entries(d) {
40 i := e.K.(uint32)
41 v := reflect.ValueOf(e.V)
42 sl.Index(int(i)).Set(v)
43 }
44
45 return alloc(sl.Interface()), uint32(d.Len())
46}
47
48// unpackMap takes a dense map of u32 -> structure, flattens the map into
49// a slice, allocates the appropriate data and returns it as well as the

Callers 5

unpackMapFunction · 0.85
createRenderPassMethod · 0.85

Calls 9

MakeSliceMethod · 0.80
EntriesMethod · 0.80
InterfaceMethod · 0.80
KeyTyMethod · 0.65
ValTyMethod · 0.65
LenMethod · 0.65
SetMethod · 0.65
IndexMethod · 0.65
TypeOfMethod · 0.45

Tested by

no test coverage detected