From aa1f53c83e4fbccde7f21555a9e5230a8652309a Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Thu, 31 Mar 2022 14:04:51 -0500 Subject: Use pointers for struct functions to avoid copies --- segmenttree.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/segmenttree.go b/segmenttree.go index edda5c0..066c1f1 100644 --- a/segmenttree.go +++ b/segmenttree.go @@ -10,7 +10,7 @@ type segmentTree struct { } // Build segment tree -func (s segmentTree) Build(a *sql.Rows, l, r, n int) { +func (s *segmentTree) Build(a *sql.Rows, l, r, n int) { if l == r { a.Next() a.Scan(&s.seg[n]) @@ -23,7 +23,7 @@ func (s segmentTree) Build(a *sql.Rows, l, r, n int) { } // Update value at index x -func (s segmentTree) Update(x, v, l, r, n int) { +func (s *segmentTree) Update(x, v, l, r, n int) { if l == r { s.seg[n] = v return @@ -38,7 +38,7 @@ func (s segmentTree) Update(x, v, l, r, n int) { } // Find element with prefix sum v -func (s segmentTree) Query(v, l, r, n int) (int, int) { +func (s *segmentTree) Query(v, l, r, n int) (int, int) { if l == r { return s.seg[n], l } -- cgit v1.2.3-70-g09d2