Hi folks! New to using reflection APIs. I was wond...
# reflect
d
Hi folks! New to using reflection APIs. I was wondering what the performance impact would be for
::functionReference.name
? More details in the 🧵
✔️ 1
Copy code
class MyClass {
  fun myFunction() {
    ...
    Log.d("${::myFunction.name)})
  }
}
What would be a problem with this?
In some cases I have seen projects log functions names for various reasons. I wanted to ensure if the function is ever renamed that the log would stay up to date to. Is this too clever? What is the trade off?
s
Although KT-16304 is still open, the linked ticket https://youtrack.jetbrains.com/issue/KT-11531 is already completed. Access to names of all callables is optimised so you will just see a string constant in the bytecode 👌👍. This solution for logging function names looks good to me, and won't have a performance cost. If you want to check for yourself, you can use the bytecode viewer.
K 2
🎉 2
thank you color 1