good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
temple
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
util
temple
Commits
6cc2918a
Commit
6cc2918a
authored
Nov 21, 2022
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
take in pointers to prevent passing sync.map by value
parent
b13a35b4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/mapn/mapn.tmpl
+14
-14
14 additions, 14 deletions
examples/mapn/mapn.tmpl
examples/mapn/maps/maps.go
+2045
-2045
2045 additions, 2045 deletions
examples/mapn/maps/maps.go
examples/mapn/reltypedef.tmpl
+2
-1
2 additions, 1 deletion
examples/mapn/reltypedef.tmpl
with
2061 additions
and
2060 deletions
examples/mapn/mapn.tmpl
+
14
−
14
View file @
6cc2918a
...
...
@@ -3,7 +3,7 @@ import (
{{range $curCount := iterateFromN 1 .Count}}
type {{template "generictypedef" $curCount}} struct {
inner Map1[K0, {{template "reltypedef" (list (sub $curCount 1) 1)}}]
inner
*
Map1[K0, {{template "reltypedef" (list (sub $curCount 1) 1
false
)}}]
}
func (m *{{template "typedef" $curCount}}) Load({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
...
...
@@ -44,10 +44,10 @@ value V) {
{{range $subCurCount:= iterateFromN 0 (add $curCount 1)}}
func (m *{{template "typedef" $curCount}}) Load{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, ok bool) {
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}, ok bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
...
...
@@ -62,7 +62,7 @@ func (m *{{template "typedef" $curCount}}) Delete{{$subCurCount}}({{range $val :
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
...
...
@@ -72,12 +72,12 @@ func (m *{{template "typedef" $curCount}}) Delete{{$subCurCount}}({{range $val :
}
func (m *{{template "typedef" $curCount}}) Range{{$subCurCount}}({{range $val := (iterateFromN 0 $subCurCount) }}k{{$val}} K{{$val}}, {{end}}
f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) bool) {
f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}) bool) {
var ok bool
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
...
...
@@ -87,10 +87,10 @@ f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $sub
}
func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, loaded bool) {
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}, loaded bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, loaded = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !loaded {
return
...
...
@@ -100,21 +100,21 @@ func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range
}
func (m *{{template "typedef" $curCount}}) LoadOrStore{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
v {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, loaded bool) {
v {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}, loaded bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .
true
)}}{})
{{end}}
return item{{$subCurCount}}.LoadOrStore0(k{{$subCurCount}}, v)
}
func (m *{{template "typedef" $curCount}}) Store{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) {
value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1)
false
)}}) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .
false
)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .
true
)}}{})
{{end}}
item{{$subCurCount}}.Store0(k{{$subCurCount}}, value)
}
...
...
This diff is collapsed.
Click to expand it.
examples/mapn/maps/maps.go
+
2045
−
2045
View file @
6cc2918a
This diff is collapsed.
Click to expand it.
examples/mapn/reltypedef.tmpl
+
2
−
1
View file @
6cc2918a
{{$count := (index . 0) -}}
{{$offset := (index . 1) -}}
{{$make := (index . 2) -}}
{{if eq $count -1 -}}
V
{{- else -}}
Map{{add 1 $count}}[
{{if $make}}&{{else}}*{{end}}
Map{{add 1 $count}}[
{{- range $val := iterateFromN $offset (add 1 $count) -}}
K{{$val}},
{{- end -}}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment