diff options
author | Anthony Wang | 2022-03-31 14:04:51 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-31 14:04:51 -0500 |
commit | aa1f53c83e4fbccde7f21555a9e5230a8652309a (patch) | |
tree | 56732df7dbf1c6bb2b705d07f0a351aaddccfe4d | |
parent | d39bb36216ba896096cc1a9f61f09b14002b59e5 (diff) |
Use pointers for struct functions to avoid copies
-rw-r--r-- | segmenttree.go | 6 |
1 files 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 } |