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
Use std::from_chars instead of std::regex+std::atof #40956
Use std::from_chars instead of std::regex+std::atof #40956
Conversation
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40956/34439
Code check has found code style and quality issues which could be resolved by applying following patch(s)
|
a178cc6
to
93aada5
Compare
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40956/34440
|
A new Pull Request was created by @makortel (Matti Kortelainen) for master. It involves the following packages:
@cmsbuild, @mandrenguyen, @clacaputo can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@cmsbuild, please test for CMSSW_13_1_ASAN_X |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-2a4c73/31055/summary.html |
please test run tests for default (master) IB |
++first; | ||
} | ||
const auto [ptr, ec] = std::from_chars(first, last, result); | ||
return ec == std::errc(); |
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.
return ec == std::errc(); | |
return ec == std::errc() and ptr == last; |
I think the condition signifying "is a number" should be stricter in this case, because of the specifics of this plugin.
Looks like weight
is a cms.string
in the PSet in order to decide at runtime if the "weight" is (1) just a number, or (2) an expression/function.
With this PR as is, weight = cms.string("45 + 3")
(or, "45 + 4*pt"
) would be translated internally to weight_ == 45.
and usesFunction_ == false
, which is not the intended behaviour (afaiu). Test code is here.
PS. Regarding
A potential downside is the larger amount of code.
I guess (didn't test) one way to reduce code is to just rely on weightExpr_
regardless (removing weight_
and usesFunction_
), but maybe this is significantly less efficient in cases like weight = cms.string("45")
(?).
-1 Failed Tests: RelVals-INPUT RelVals-INPUT
Comparison SummarySummary:
|
Superseded by #40984 |
PR description:
This PR explores an alternative to #40915 to fix #40902 with
std::from_chars
(avoiding exceptions, use of locale, etc).PR validation:
Code compiles.