http://quantlib.414.s1.nabble.com/Repetitive-function-calls-in-discountingbondengine-cpp-tp12769p12770.html
Done, thanks.
>
> 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.
>
>
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create
> new or port existing apps to sell to consumers worldwide. Explore the
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
>
http://p.sf.net/sfu/intel-appdev> _______________________________________________
> QuantLib-dev mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-devWrite once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join