Compiler optimization

Hello all, I have a question about how the Arduino compiler optimizes code. I have written a library to do vector operations and matrix transformations and a few of the functions are computationally heavy. If I write a sketch that does not use certain functions from a library, do they get optimized out so they do not take additional memory?

For example, if I include the Servo library and do not use servo.detach(), does it get optimized out (assuming servo was properly declared/initialized)?

Thanks!

In general, unused functions are optimised out.

The compiler compiles the code, and creates an object file. The linker pulls the pieces that it needs (what ACTUALLY gets called). It's not really a matter of "optimizing out" anything. It's a matter of copying IN what is actually used.

They better be pretty small matrices!