Search Apps Documentation Source Content File Folder Download Copy Actions Download

getter_utils.gno

1.42 Kb · 85 lines
 1package staker
 2
 3func cloneStringSlice(src []string) []string {
 4	if src == nil {
 5		return nil
 6	}
 7	copied := make([]string, len(src))
 8	copy(copied, src)
 9	return copied
10}
11
12func cloneUint64Slice(src []uint64) []uint64 {
13	if src == nil {
14		return nil
15	}
16	copied := make([]uint64, len(src))
17	copy(copied, src)
18	return copied
19}
20
21func cloneInt64Slice(src []int64) []int64 {
22	if src == nil {
23		return nil
24	}
25	copied := make([]int64, len(src))
26	copy(copied, src)
27	return copied
28}
29
30func cloneInt32Slice(src []int32) []int32 {
31	if src == nil {
32		return nil
33	}
34	copied := make([]int32, len(src))
35	copy(copied, src)
36	return copied
37}
38
39func cloneStringInt64Map(src map[string]int64) map[string]int64 {
40	if src == nil {
41		return nil
42	}
43
44	copied := make(map[string]int64, len(src))
45	for key, value := range src {
46		copied[key] = value
47	}
48	return copied
49}
50
51func cloneStringBoolMap(src map[string]bool) map[string]bool {
52	if src == nil {
53		return nil
54	}
55
56	copied := make(map[string]bool, len(src))
57	for key, value := range src {
58		copied[key] = value
59	}
60
61	return copied
62}
63
64func cloneExternalIncentives(src []ExternalIncentive) []ExternalIncentive {
65	if src == nil {
66		return nil
67	}
68
69	copied := make([]ExternalIncentive, len(src))
70	for i := range src {
71		copied[i] = *src[i].Clone()
72	}
73
74	return copied
75}
76
77func cloneWarmups(warmups []Warmup) []Warmup {
78	if warmups == nil {
79		return nil
80	}
81
82	copied := make([]Warmup, len(warmups))
83	copy(copied, warmups)
84	return copied
85}