Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: using unsafe.String and unsafe.SliceData #21412

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### Improvements

* (client) [#21436](https://github.com/cosmos/cosmos-sdk/pull/21436) Use `address.Codec` from client.Context in `tx.Sign`.
* (internal) [#21412](https://github.com/cosmos/cosmos-sdk/pull/21412) Using unsafe.String and unsafe.SliceData.

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion internal/conv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func UnsafeStrToBytes(s string) []byte {
// to be used generally, but for a specific pattern to delete keys
// from a map.
func UnsafeBytesToStr(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
return unsafe.String(unsafe.SliceData(b), len(b))
}
2 changes: 1 addition & 1 deletion store/internal/conv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func UnsafeStrToBytes(s string) []byte {
// to be used generally, but for a specific pattern to delete keys
// from a map.
func UnsafeBytesToStr(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
return unsafe.String(unsafe.SliceData(b), len(b))
}
2 changes: 1 addition & 1 deletion store/v2/internal/conv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func UnsafeStrToBytes(s string) []byte {
// to be used generally, but for a specific pattern to delete keys
// from a map.
func UnsafeBytesToStr(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
return unsafe.String(unsafe.SliceData(b), len(b))
}
2 changes: 1 addition & 1 deletion x/authz/internal/conv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ func UnsafeStrToBytes(s string) []byte {
// to be used generally, but for a specific pattern to delete keys
// from a map.
func UnsafeBytesToStr(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
return unsafe.String(unsafe.SliceData(b), len(b))
}
2 changes: 1 addition & 1 deletion x/nft/internal/conv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func UnsafeStrToBytes(s string) []byte {
// to be used generally, but for a specific pattern to delete keys
// from a map.
func UnsafeBytesToStr(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
return unsafe.String(unsafe.SliceData(b), len(b))
}
Loading