Skip to content

Commit

Permalink
feat: nocheckptr for rt.IndexChar
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Oct 26, 2023
1 parent 53c974e commit 8254f72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/rt/fastmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ func FuncAddr(f interface{}) unsafe.Pointer {
}
}

//go:nocheckptr
func IndexChar(src string, index int) unsafe.Pointer {
return unsafe.Pointer(uintptr((*GoString)(unsafe.Pointer(&src)).Ptr) + uintptr(index))
}

//go:nocheckptr
func IndexByte(ptr []byte, index int) unsafe.Pointer {
return unsafe.Pointer(uintptr((*GoSlice)(unsafe.Pointer(&ptr)).Ptr) + uintptr(index))
}

//go:nosplit
func GuardSlice(buf *[]byte, n int) {
c := cap(*buf)
l := len(*buf)
Expand Down

0 comments on commit 8254f72

Please sign in to comment.