c - How does const pointer arguments optimized when calling functions? -


how compilers optimizes theese 4 types of function definitions. there optimization done in sense of argument passing?

int check_collision(const sdl_rect const *a,const sdl_rect const *b) { ... }  int check_collision(sdl_rect const *a,sdl_rect const *b) { ... }  int check_collision(const sdl_rect *a, sdl_rect const *b) { ... }  int check_collision(sdl_rect *a, sdl_rect *b) { ... } 

and if matters, think preferable way of passing read arguments function in cases these argument might inefficent copy when calling funcion?

use const in of these cases indicate purpose of usage more , writing more readable code, modern day compilers efficient , smart enough apply required optimization's whether pass function argument const or not.

in short, use const in case readability & preventing usage errors, & not compiler optimization,
compiler smart enough take care of that.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -