Discussion:
[webkit-help] Passing RefPtr<T> to function expecting Ref<T>
Konstantin Tokarev
2017-03-26 19:28:13 UTC
Permalink
Hello,

What is the most appropriate way to do subject, given that ptr is RefPtr<T>?

1. f(*ptr)
2. f(ptr.releaseNonNull())

Any difference when ptr is lvalue or rvalue?
--
Regards,
Konstantin
Ryosuke Niwa
2017-03-27 06:37:37 UTC
Permalink
Post by Konstantin Tokarev
Hello,
What is the most appropriate way to do subject, given that ptr is RefPtr<T>?
1. f(*ptr)
2. f(ptr.releaseNonNull())
Both forms are depending on what you're trying to do. 1 is appropriate
and necessary if ptr is used after the call to f but it results in an
unnecessary ref-churn if ptr is never used after the call. 2 is
appropriate if ptr is never after the call, and would avoid a
ref-churn.

- R. Niwa
Konstantin Tokarev
2017-03-27 06:46:47 UTC
Permalink
Post by Ryosuke Niwa
 Hello,
 What is the most appropriate way to do subject, given that ptr is RefPtr<T>?
 1. f(*ptr)
 2. f(ptr.releaseNonNull())
Both forms are depending on what you're trying to do. 1 is appropriate
and necessary if ptr is used after the call to f but it results in an
unnecessary ref-churn if ptr is never used after the call. 2 is
appropriate if ptr is never after the call, and would avoid a
ref-churn.
- R. Niwa
Thanks!
--
Regards,
Konstantin
Loading...