Is something like this code considered a bad practice?
If so, what should I do when func1
duplicates func2
's behavior and I need both functions to be present (isn't that considered code redundancy)?!
UPD: Sorry for my bad illustration, I'll try to explain the question more clearly.
What i wanted to ask about is that:
I'm trying to design an optimized class that heavily calls two methods func1
and func2
, func1
's implementation uses func2
and i want the two methods calls to be inlined as much as possible, So is it better to call func2
from func1
like this code or to implement both independently.
inline int func2(int x) {
return x * (x + 2);
}
inline int func1(int x) {
return x * (x + 1) * func2(x + 2);
}