summaryrefslogtreecommitdiff
path: root/sortFunc.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-11 02:44:21 -0600
committerJeff Carr <[email protected]>2025-01-11 02:44:21 -0600
commit9349ab95fc91f74f2c242a7e3ccc0b630c3d95f3 (patch)
treecaaf75c3d0da4392a57e0d32b137435160b67d0e /sortFunc.go
parent3f2909aa0d95acc5b00642d082013afd40108a30 (diff)
small app works, example core dumps on Marshal()
Diffstat (limited to 'sortFunc.go')
-rw-r--r--sortFunc.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/sortFunc.go b/sortFunc.go
index e12db51..361462b 100644
--- a/sortFunc.go
+++ b/sortFunc.go
@@ -57,18 +57,18 @@ func (pf *File) selectAllFunc(w io.Writer) {
var BASE string = pf.Base.Name
var LOCK string = pf.Bases.Lockname
- fmt.Fprintln(w, "func (all *"+BASES+") All() *"+BASE+"Iterator {")
- fmt.Fprintln(w, " "+BASE+"Pointers := all.selectAll"+BASE+"()")
+ fmt.Fprintln(w, "func (x *"+BASES+") All() *"+BASE+"Iterator {")
+ fmt.Fprintln(w, " "+BASE+"Pointers := x.selectAll"+BASE+"()")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " iterator := New"+BASE+"Iterator("+BASE+"Pointers)")
fmt.Fprintln(w, " return iterator")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
- fmt.Fprintln(w, "func (all *"+BASES+") Len() int {")
+ fmt.Fprintln(w, "func (x *"+BASES+") Len() int {")
fmt.Fprintln(w, " "+LOCK+".RLock()")
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
fmt.Fprintln(w, "")
- fmt.Fprintln(w, " return len(all."+BASES+")")
+ fmt.Fprintln(w, " return len(x."+BASES+")")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
}
@@ -78,8 +78,8 @@ func (pf *File) sortByFunc(w io.Writer) {
var BASE string = pf.Base.Name
for _, SORT := range pf.Base.Sort {
- fmt.Fprintln(w, "func (all *"+BASES+") SortBy"+SORT+"() *"+BASE+"Iterator {")
- fmt.Fprintln(w, " things := all.selectAll"+BASE+"()")
+ fmt.Fprintln(w, "func (x *"+BASES+") SortBy"+SORT+"() *"+BASE+"Iterator {")
+ fmt.Fprintln(w, " things := x.selectAll"+BASE+"()")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " sort.Sort("+BASE+""+SORT+"(things))")
fmt.Fprintln(w, "")
@@ -103,14 +103,14 @@ func (pf *File) iterSelect(w io.Writer) {
var LOCK string = pf.Bases.Lockname
fmt.Fprintln(w, "// safely returns a slice of pointers to the "+BASE+" protobufs")
- fmt.Fprintln(w, "func (all *"+BASES+") selectAll"+BASE+"() []*"+BASE+" {")
+ fmt.Fprintln(w, "func (x *"+BASES+") selectAll"+BASE+"() []*"+BASE+" {")
fmt.Fprintln(w, " "+LOCK+".RLock()")
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " // Create a new slice to hold pointers to each "+BASE+"")
fmt.Fprintln(w, " var tmp []*"+BASE+"")
- fmt.Fprintln(w, " tmp = make([]*"+BASE+", len(all."+BASES+"))")
- fmt.Fprintln(w, " for i, p := range all."+BASES+" {")
+ fmt.Fprintln(w, " tmp = make([]*"+BASE+", len(x."+BASES+"))")
+ fmt.Fprintln(w, " for i, p := range x."+BASES+" {")
fmt.Fprintln(w, " tmp[i] = p // Copy pointers for safe iteration")
fmt.Fprintln(w, " }")
fmt.Fprintln(w, "")