Skip to content

Commit

Permalink
feat: refactor copyInt and readInt to use unsafe.Slice
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoutsovasilis committed Jan 24, 2024
1 parent cd3c3b1 commit ced2232
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions auditbeat/tracing/int_aligned.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
var errBadSize = errors.New("bad size for integer")

func copyInt(dst unsafe.Pointer, src unsafe.Pointer, len uint8) error {
copy((*(*[maxIntSizeBytes]byte)(dst))[:len], (*(*[maxIntSizeBytes]byte)(src))[:len])
copy(unsafe.Slice((*byte)(dst), len), unsafe.Slice((*byte)(src), len))
return nil
}

func readInt(ptr unsafe.Pointer, len uint8, signed bool) (any, error) {
var value any
asSlice := (*(*[maxIntSizeBytes]byte)(ptr))[:]
asSlice := unsafe.Slice((*byte)(ptr), len)
switch len {
case 1:
if signed {
Expand Down

0 comments on commit ced2232

Please sign in to comment.