-
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.
- Loading branch information
Tao Wen
committed
Sep 11, 2021
1 parent
9f87197
commit 8358028
Showing
6 changed files
with
45 additions
and
29 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/modern-go/reflect2 | ||
|
||
go 1.18 | ||
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