eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches

Home Page:https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance improvement can be made for `Marshaler.Get`.

sean2077 opened this issue · comments

Performance improvement can be made for Marshaler.Get.

image

Here []bytes(v) can be replace with String2Bytes(v) cast funciton.

func String2Bytes(s string) []byte {
	sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
	bh := reflect.SliceHeader{
		Data: sh.Data,
		Len:  sh.Len,
		Cap:  sh.Len,
	}
	return *(*[]byte)(unsafe.Pointer(&bh))
}