英文:
Does any has performance difference between Extension Function and Infix Functions in Kotlin/Java
问题
在扩展函数和中缀函数之间是否存在性能差异?谢谢。
英文:
something stuck in my head, I would like to ask you here. I searched the web but couldn't find it. Is there any performance difference between Extension Functions and Infix Functions ? Thanks.
答案1
得分: 9
他们是苹果和橙子,关于它们的性能问题实际上没有太多意义。
在大多数情况下,扩展实际上是一个静态函数,其性能与任何其他静态函数相同。
中缀函数只是提供了调用函数的另一种语法方式。中缀函数可以是常规成员函数或扩展。它们与它们的非中缀等效函数具有相同的性能。
英文:
They are apples and oranges and the question about their performance doesn't really make too much sense.
Extension in most cases is effectively a static function and its performance is the same as any other static function.
Infix function simply provides an alternative syntax for calling a function. Infix function could be both a regular member function or an extension. They have the same performance as their non-infix equivalents.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论