|
From: StephenWong <ste...@gm...> - 2011-12-22 22:47:00
|
Within the file ql/pricingengines/bond/discountingbondengine.cpp there is the
DiscountingBondEngine::calculate() method. Within this method, it sets
results_.value and results_.settlementValue by calling the
CashFlows::npv(...) function each time. It does this even if all the
arguments of the two calls are identical.
Can we not check the arguments first and if they are identical, just call
the CashFlows::npv(...) once? It is a bit of an eye sore for me to see all
the other functions being called within CashFlows::npv(...) over and over
even if there is no such need?
More explicitly, after the line
results_.value = CashFlows::npv(arguments_.cashflows,
**discountCurve_,
includeRefDateFlows,
results_.valuationDate,
results_.valuationDate);
just insert
if ( includeRefDateFlows == false && results_.valuationDate ==
arguments_.settlementDate )
results_.settlementValue = results.value;
else {
results_.settlementValue = CashFlows::npv(arguments_.cashflows,
**discountCurve_,
false,
arguments_.settlementDate,
arguments_.settlementDate);
}
I know this does not look like much but it is a bit of a pain in the neck if
one is going through the code, debugging etc and see all the function calls
being made over and over when there is no need.
--
View this message in context: http://old.nabble.com/Repetitive-function-calls-in-discountingbondengine.cpp-tp33026149p33026149.html
Sent from the quantlib-dev mailing list archive at Nabble.com.
|