cpp-io2d/P0267_RefImpl

Use float instead of doubles

TerensTare opened this issue · 4 comments

Since this is supposed to be the "standard way" of doing 2d graphics in C++, I think we need it to be as fast as it can. From what I saw from the implementation, vector_2d and rectangle use double for members. C++ also offers a float type with smaller precision, but which is proven to be faster. I personally have been using float for my Vector2d class and I have seen no problems, so I think the implementation would gain some performance by using floats.

Apparently, if we do computations on GPU, floats are faster (link here). But on Android, floats are even slower than ints (link here).

before this gets religious ... i checked the source. can you provide links? i've found almost all double usage is in the examples and graphics backends, but not the main implementation:

https://github.com/cpp-io2d/P0267_RefImpl/search?q=double&unscoped_q=double

I read the paper about this proposal (Revision 6). There I saw two classes (namely vector_2d and rectangle), which used double for members. I found a fork of this repo with the implementation of these classes. I decided to file an issue there, but since you can't open an issue on a fork, I went to this repo (the parent one). It appears that the forked repo is some commits (and a revision) behind this one, as the classes are now renamed to basic_point_2d and basic_bounding_box and use float for members. Guess it was just my bad at all😅😅.