We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Thanks for your contribution, and I do have a suggestion which may make this library better.
I'm using this library to write a code generator with generics, and I cannot predict which specific type the user may call.
type DeepCopyGen[T any] interface { DeepCopyInto(*T) } func DeepCopy[T any](in, out *T) { var _in any = in if d, ok := _in.(DeepCopyGen[T]); ok { // use deepcopy-gen d.DeepCopyInto(out) return } // Have to call pcopy.Preheat each time pcopy.Copy(in, out, pcopy.WithUsePreheat()) }
if pcopy.Copy enables preheat by default, then things go easy. Just call pcopy.Copy(in, out) is enough.
pcopy.Copy
pcopy.Copy(in, out)
The process could be as follows:
getFromCacheSetAndRun
get
run
(*allFieldFunc, bool)
nil, false
newAllFieldFunc
saveToCache
*allFieldFunc.do
opts ...Option
What do you think? @guonaihong
The text was updated successfully, but these errors were encountered:
看你是国人。那就用中文回答了。当pcopy足够稳定的时候会默认启用预热。 我压测过,每次使用时都调用Preheat和Copy函数和单调Copy时间类似,因为预热函数会检查类型是否会有缓存,如果存在缓存就会直接跳过。
pcopy.Preheat(&dst{}, &src{}) // 一对类型只要预热一次 pcopy.Copy(&d, &s, pcopy.WithUsePreheat())
所以对于你的需求来说,实现一个万能的高性能deepcopy函数。先检查是否实现DeepCopyGen接口,如果没有实现直接调用Preheat和Copy和启动预热实际是一样,只是多调用了一行代码。
Sorry, something went wrong.
No branches or pull requests
Thanks for your contribution, and I do have a suggestion which may make this library better.
I'm using this library to write a code generator with generics, and I cannot predict which specific type the user may call.
if
pcopy.Copy
enables preheat by default, then things go easy. Just callpcopy.Copy(in, out)
is enough.The process could be as follows:
getFromCacheSetAndRun
intoget
andrun
, theget
function returns(*allFieldFunc, bool)
get
returnsnil, false
, callnewAllFieldFunc
andsaveToCache
*allFieldFunc.do
opts ...Option
argument can be removedWhat do you think? @guonaihong
The text was updated successfully, but these errors were encountered: