If the compiler knows about the most derived class, it doesn't need to access the vtable to resolve the actual method call.

so when everything is known to the compiler at compile time, the virtualness doesn't cost you anything.

that said a virtual method call is cheap when ammortized over a block of samples as stephane said.

here's a toy example using CompilerExplorer to look at the generated code:
https://godbolt.org/g/u8mH8b

the difference is just one mov for the vtable (with -O1)

On 27/11/17 19:04, stijn . wrote:
In my use case I would like to embed faust code within my own node-based modular DSP system. Therefore I would like to composite a faust-generated dsp class within my own Node class. In that case I would use a templated Node<MyFaustDSPClass> that would call MyFaustDSPClass's methods to compute it's output. Then it would not be desirable for MyFauseDSPClass to have any base class or virtual methods though, because no polymorphism is used I would only loose the extra CPU cost of the virtual method calls.

Is there a way to disable the "virtual" keyword in faust's output?

Thanks a lot,

Stijn.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to