Skip to content

Commit

Permalink
chore(decoder): use unsafe.String
Browse files Browse the repository at this point in the history
This raises the minimum Go version to 1.20
  • Loading branch information
guelfey committed Sep 21, 2024
1 parent c80783f commit 33c352a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ D-Bus message bus system.

### Installation

This packages requires Go 1.12 or later. It can be installed by running the command below:
This packages requires Go 1.20 or later. It can be installed by running the command below:

```
go get github.com/godbus/dbus/v5
Expand Down
8 changes: 1 addition & 7 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,6 @@ func (c *stringConverter) String(b []byte) string {
}

// toString converts a byte slice to a string without allocating.
// Starting from Go 1.20 you should use unsafe.String.
func toString(b []byte) string {
var s string
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
h.Data = uintptr(unsafe.Pointer(&b[0]))
h.Len = len(b)

return s
return unsafe.String(&b[0], len(b))
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/godbus/dbus/v5

go 1.12
go 1.20

require golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2

0 comments on commit 33c352a

Please sign in to comment.