J
junky_fellow
I have read certain articles that encourage to use/write
pure functions (if possible) as they are better suited for
optimization.
I got one example that expalins how the code can be optimised.
For eg:
__pure int square(int x)
{
return x * x;
}
int f(int n)
{
return square(n) + square(n);
}
The function f() can be optimised to call pure function square() once.
Is there any other way pure functions help in optimization ?
Is the pure function itself produce much optimized code as compared
to non pure functions ?
pure functions (if possible) as they are better suited for
optimization.
I got one example that expalins how the code can be optimised.
For eg:
__pure int square(int x)
{
return x * x;
}
int f(int n)
{
return square(n) + square(n);
}
The function f() can be optimised to call pure function square() once.
Is there any other way pure functions help in optimization ?
Is the pure function itself produce much optimized code as compared
to non pure functions ?