c++ good programming practice and performance tips
Performance tips
- Use nested if else rather then all If statements.
- Use small integer size
- For or the condition most likely to be true place at left and for && condit most likely t be false place at left
- For(int i=0;i<bla ;i++); the loop will continue to work
- Do pass arguments by reference. Object s as reference
- Initialize the array at program time rather then at run time
- Use static with the array if u do not want it to be destroyed and reinitialize
- Use const if u do not want th e original array to b emodified
- If there is only a single function which uses another call to the function then u need to proto type that function in this one for example
Void rana(){
Void test();
}
void test(){
}
- Th e above mentioned way should be used.
- Passing the arrays and the pointers are interchangeable cuz if u pass an array to a function a pointr would be passed.
- The sizeof an array is the total bytes occupied by the array elements.
- If u want to do pointer arithmetic then do it only on an array
- Do not dereference the void pointers
- Initialize the array of function pointers the same way u initialize the other arrays
0 comments: