Normally a library supports various kinds of components; because mostly those components share a lot functionality, so it prevents to make very many different libraries.
Note that all functions that you do not call within your program (and are not called from within the library), will NOT end up in your sketch, thus also will not affect your flash memory usage.
If the library is full of if
statements to make a difference between models, that code is in (if a function is called, the entire function is stored in flash). (Unless the if
statement can be evaluated compile time, see remark of Edgar Bonet below about link time optimization).
So if you want to remove that 'unnecessary' code (for you at least), than copy the library into your project and remove the unnecessary code yourself.
However, I would not do that until you run out of flash memory.
You can do an easy test:
- Include a library, and compile your sketch. You will see (possibly) some difference.
- Now call a function from the library. Compile the sketch again, you will see the flash memory usage has increased. This means, before that, that function was not part of your compiled sketch.
A thing I would worry more about, is SRAM memory usage, but mostly buffers are created depending on the model, and SRAM is not wasted (since the Arduino Uno has only 2 KB for example).