-
Notifications
You must be signed in to change notification settings - Fork 460
Adjust #11051 - Fix EPVector out of range issue: good candidate for a lambda! #11080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| auto writeDSOAToPredefined = [&state, &vent_mech, &thisMechVentZone](const OARequirementsData &dsoa, | ||
| const std::string &zoneOrSpaceName) { | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVventMechName, zoneOrSpaceName, vent_mech.Name); | ||
| OutputReportPredefined::PreDefTableEntry(state, | ||
| state.dataOutRptPredefined->pdchDCVType, | ||
| zoneOrSpaceName, | ||
| SysOAMethodNames[static_cast<int>(vent_mech.SystemOAMethod)]); | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVperPerson, zoneOrSpaceName, dsoa.OAFlowPerPerson, 6); | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVType, zsName, SysOAMethodNames[static_cast<int>(vent_mech.SystemOAMethod)]); | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVperPerson, zsName, dsoa2.OAFlowPerPerson, 6); | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVperArea, zsName, dsoa2.OAFlowPerArea, 6); | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVperZone, zsName, dsoa2.OAFlowPerZone, 6); | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVperACH, zsName, dsoa2.OAFlowACH, 6); | ||
| state, state.dataOutRptPredefined->pdchDCVperArea, zoneOrSpaceName, dsoa.OAFlowPerArea, 6); | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVMethod, zsName, OAFlowCalcMethodNames[static_cast<int>(dsoa2.OAFlowMethod)]); | ||
| if (dsoa2.oaFlowFracSched != nullptr) { | ||
| state, state.dataOutRptPredefined->pdchDCVperZone, zoneOrSpaceName, dsoa.OAFlowPerZone, 6); | ||
| OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDCVperACH, zoneOrSpaceName, dsoa.OAFlowACH, 6); | ||
| OutputReportPredefined::PreDefTableEntry(state, | ||
| state.dataOutRptPredefined->pdchDCVMethod, | ||
| zoneOrSpaceName, | ||
| OAFlowCalcMethodNames[static_cast<int>(dsoa.OAFlowMethod)]); | ||
| if (dsoa.oaFlowFracSched != nullptr) { | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVOASchName, zsName, dsoa2.oaFlowFracSched->Name); | ||
| state, state.dataOutRptPredefined->pdchDCVOASchName, zoneOrSpaceName, dsoa.oaFlowFracSched->Name); | ||
| } | ||
| if (thisMechVentZone.zoneADEffSched != nullptr) { | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffSchName, zsName, thisMechVentZone.zoneADEffSched->Name); | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffSchName, zoneOrSpaceName, thisMechVentZone.zoneADEffSched->Name); | ||
| } else { | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffCooling, zsName, thisMechVentZone.ZoneADEffCooling, 2); | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffCooling, zoneOrSpaceName, thisMechVentZone.ZoneADEffCooling, 2); | ||
| OutputReportPredefined::PreDefTableEntry( | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffHeating, zsName, thisMechVentZone.ZoneADEffHeating, 2); | ||
| state, state.dataOutRptPredefined->pdchDCVZoneADEffHeating, zoneOrSpaceName, thisMechVentZone.ZoneADEffHeating, 2); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lambdas for the win.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just make a normal function? Lambdas are for passing functions as arguments to other functions, not for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's your personal interpretation of what lambdas are, but it's not mine.
Lambdas are inline, anonymous functions, and they can take a closure, and they are (in my opinion) a great way to do what I've just did, which is to 1) fix the issue and 2) dry up the code.
Sure, you can write a function. But I don't see it being used anywhere else, and you're going to have to pass a bunch of parameters, and probably re-access thisMechVentZone. And now the logic to do stuff is further away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just explaining why I like it, you can still ask @mjwitte to do it with a function on the original PR of course :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I'm not going to ask @mjwitte to do anything.
| if (dsoa.numDSOA == 0) { | ||
| writeDSOAToPredefined(dsoa, zoneName); | ||
| } else { | ||
| for (int n = 0; n < dsoa.numDSOA; ++n) { | ||
| writeDSOAToPredefined(state.dataSize->OARequirements(dsoa.dsoaIndexes[n]), format("{}:{}", zoneName, dsoa.dsoaSpaceNames[n])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now it's short, sweet, and clear.
|
Alright confirmed that my MCVEs now run to completion. |
mjwitte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Description of the purpose of this PR
Pull Request Author
Reviewer