Gan:
How can I make it use less CPU/RAM?
Most tiny classes probably should be structs. More generally, use a struct every time you don't need a class.
You can start with those two: struct SBRange { double left = 0.0, right = 0.0, top = 0.0, bottom = 0.0; } struct Point(T) { T x, y; }This probably isn't enough to solve your problems, but it's a start.
Bye, bearophile