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 the standard library fabs() #1495
Comments
Oops, now I remember why there is a need for the custom implementation. It uses |
@darbyjohnston It wasn't just constexpr, although that is the comment on the commit. We wanted specific behavior around nan and inf. To quote the C spec
There was a corner case sadly not captured in a regression test, where signs were not propagating as expected. Maybe someone else recalls more specific details. As I recall, this bit masking implementation was a deliberate choice in order to avoid underspecified behavior in the C spec. |
Interesting, we should probably add a comment that explains this. I had forgotten and my first instinct seeing it again was that it was possibly duplicated code. Also should it be a part of the public API? |
It's only in the public API because of the constexpr business. It could be made private copied twice within RationalTime and TimeRange. I'd have no argument with that, as I do concur with your implication that it is an implementation detail. It's only in the public API I'd have no argument with that But still it remains in the API Though its purpose may not be clear For efficient, reliable software
|
It would be nice to hide but I'm not a fan of duplicating the code even though it's a fairly small function. Another way of hiding it would be as a protected function in a base class but that seems a bit convoluted. I think just a comment explaining it's use would be good, I'll make a separate PR for that. I wonder if GPT3 could write Doxygen for us. :) |
I think GPT3 could in fact write documentation for us, or to put it a different way, it could write a rather prosey explanation that might provide a good starting point for clearly explaining what some code does. You can grab a function and ask it "Explain the following code: ". Josh has been experimenting with it. |
I noticed there is a custom implementation of
fabs()
inrationalTime.h
, it might be nice to replace it with the function from the standard library:https://en.cppreference.com/w/cpp/numeric/math/fabs
It would reduce the amount of code in OpenTime and remove a function that should probably not be part of the API.
The text was updated successfully, but these errors were encountered: