diff options
| author | 2025-03-09 17:47:56 +0100 | |
|---|---|---|
| committer | 2025-12-01 22:08:04 +0100 | |
| commit | b1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch) | |
| tree | 9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go | |
| parent | [chore] update URLs to forked source (diff) | |
| download | gotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz | |
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go')
| -rw-r--r-- | vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go b/vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go deleted file mode 100644 index dbced0c72..000000000 --- a/vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go +++ /dev/null @@ -1,39 +0,0 @@ -package genstack - -// stack is a wrapper around an array implementing a stack. -// -// We cannot use slice to represent the stack because append might change the -// pointer value of the slice. That would be an issue in GenStack -// implementation. -type stack[T any] struct { - arr []T -} - -// push pushes a new element at the top of a stack. -func (s *stack[T]) push(vs ...T) { s.arr = append(s.arr, vs...) } - -// pop pops the stack top-most element. -// -// If stack length is zero, this method panics. -func (s *stack[T]) pop() T { - idx := s.len() - 1 - val := s.arr[idx] - - // Avoid memory leak - var zero T - s.arr[idx] = zero - - s.arr = s.arr[:idx] - return val -} - -// takeAll returns all elements in the stack in order as they are stored - i.e. -// the top-most stack element is the last one. -func (s *stack[T]) takeAll() []T { - arr := s.arr - s.arr = nil - return arr -} - -// len returns number of elements in the stack. -func (s *stack[T]) len() int { return len(s.arr) } |
