Skip to content

Commit

Permalink
Merge 4399f62 into 87b8a9a
Browse files Browse the repository at this point in the history
  • Loading branch information
ksw2000 committed Apr 3, 2024
2 parents 87b8a9a + 4399f62 commit 4cdc83a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions array.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func arrayFromSlice(x interface{}) array {

func (a *array) Len() int { return a.Header.TypedLen(a.t.Type) }

func (a *array) Cap() int { return a.Header.TypedLen(a.t.Type) }
func (a *array) Cap() int { return a.Header.TypedCap(a.t.Type) }

// fromSlice populates the value from a slice
func (a *array) fromSlice(x interface{}) {
Expand Down Expand Up @@ -91,10 +91,8 @@ func (a *array) sliceInto(i, j int, res *array) {

s := i * int(a.t.Size())
e := j * int(a.t.Size())
c = c - i

res.Raw = a.Raw[s:e]

}

// slice slices an array
Expand Down
4 changes: 4 additions & 0 deletions internal/storage/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func (h *Header) TypedLen(t reflect.Type) int {
return len(h.Raw) / int(t.Size())
}

func (h *Header) TypedCap(t reflect.Type) int {
return cap(h.Raw) / int(t.Size())
}

func Copy(t reflect.Type, dst, src *Header) int {
copied := copy(dst.Raw, src.Raw)
return copied / int(t.Size())
Expand Down

0 comments on commit 4cdc83a

Please sign in to comment.