C++ pointers and optimization -


i have read c++ compiler optimization (,or @ least should) , programmer shouldn't worry too much it.

but how compare pointers? seems every time make function have decide whether use pointers or not. what's reason behind this? shouldn't compiler far possible?

and isn't there keyword can use in method signature states objects given parameter won't mutated compiler optimize stuff?

and why is(n't) there one?

using object argument, compiler may or may not copy ellision depending on many factors. if in doubt compiler can make safe assumption function may want change argument , may avoid copy elision optimization.

instead if use (const) reference or pointer, provides stronger guarantee compiler either object won't change or changes done locally in function required in caller also.

in general 1 should avoid avoid micro optimizations unless proven bottleneck using profiling , concentrate on readability of code better maintenance , architectural changes can give higher optimization , can not suggested/performed tools.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -