mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
✏️ 优化 getea
This commit is contained in:
parent
9de065d31a
commit
e6a20866b6
@ -62,18 +62,6 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slice is the runtime representation of a slice.
|
|
||||||
// It cannot be used safely or portably and its representation may
|
|
||||||
// change in a later release.
|
|
||||||
//
|
|
||||||
// Unlike reflect.SliceHeader, its Data field is sufficient to guarantee the
|
|
||||||
// data it references will not be garbage collected.
|
|
||||||
type slice struct {
|
|
||||||
Data unsafe.Pointer
|
|
||||||
Len int
|
|
||||||
Cap int
|
|
||||||
}
|
|
||||||
|
|
||||||
func getea(key string) tea.TEA {
|
func getea(key string) tea.TEA {
|
||||||
kr := []rune(key)
|
kr := []rune(key)
|
||||||
if len(kr) > 4 {
|
if len(kr) > 4 {
|
||||||
@ -83,8 +71,5 @@ func getea(key string) tea.TEA {
|
|||||||
kr = append(kr, rune(4-len(kr)))
|
kr = append(kr, rune(4-len(kr)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skr := *(*slice)(unsafe.Pointer(&kr))
|
return *(*tea.TEA)(*(*unsafe.Pointer)(unsafe.Pointer(&kr)))
|
||||||
skr.Len *= 4
|
|
||||||
skr.Cap *= 4
|
|
||||||
return tea.NewTeaCipher(*(*[]byte)(unsafe.Pointer(&skr)))
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user