-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from modern-go/fix-go1.18
WIP: update signature of mapiterinit of go 1.18
- Loading branch information
Showing
6 changed files
with
63 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/modern-go/reflect2 | ||
|
||
go 1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//+build go1.18 | ||
|
||
package reflect2 | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// m escapes into the return value, but the caller of mapiterinit | ||
// doesn't let the return value escape. | ||
//go:noescape | ||
//go:linkname mapiterinit reflect.mapiterinit | ||
func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer, it *hiter) | ||
|
||
func (type2 *UnsafeMapType) UnsafeIterate(obj unsafe.Pointer) MapIterator { | ||
var it hiter | ||
mapiterinit(type2.rtype, *(*unsafe.Pointer)(obj), &it) | ||
return &UnsafeMapIterator{ | ||
hiter: &it, | ||
pKeyRType: type2.pKeyRType, | ||
pElemRType: type2.pElemRType, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//+build !go1.18 | ||
|
||
package reflect2 | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// m escapes into the return value, but the caller of mapiterinit | ||
// doesn't let the return value escape. | ||
//go:noescape | ||
//go:linkname mapiterinit reflect.mapiterinit | ||
func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) (val *hiter) | ||
|
||
func (type2 *UnsafeMapType) UnsafeIterate(obj unsafe.Pointer) MapIterator { | ||
return &UnsafeMapIterator{ | ||
hiter: mapiterinit(type2.rtype, *(*unsafe.Pointer)(obj)), | ||
pKeyRType: type2.pKeyRType, | ||
pElemRType: type2.pElemRType, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters