On Mon, 03 Mar 2014 21:48:16 -0500, Casper Færgemand <shortt...@gmail.com>
wrote:
Is there any loss in performance instantiating an interface variable as
a final class implementing only that interface, as opposed to a class
variable?
You mean the difference between:
final class C : I {...}
// this
I i = new C;
// and this
C c = new C;
???
The difference in performance is huge. As a final class, no virtual calls
are needed. In itself, this is not a huge deal, as a virtual call is not
too much worse than a standard call.
However, method calls on the concrete class can be inlined, and an inline
call is generally very quick when compared to any kind of other call.
-Steve