rive-app / rive-cpp-legacy

C++ runtime for Rive
MIT License
287 stars 43 forks source link

refactor Vec2D methods #165

Closed mikerreed closed 2 years ago

mikerreed commented 2 years ago
  1. make trivial methods inline
  2. return by value when that is natural (more readable, and allows caller to have const results)
  3. use methods instead of static functions when applicable (e.g. Vec2D::length(a) --> a.length())

I expect that passing Vec2D by value is more efficient than by const& (modern abis can pass 2 (or 4) floats as a single arg) but will explore that later.

mikerreed commented 2 years ago

This is a big diff -- but I think the resulting call sites are all more readable (and can be more efficient for the compiler)

luigi-rosso commented 2 years ago

We should also be aware this may cause breaking changes downstream with some of the iOS/Android/WASM runtimes too. Which is fine!

mikerreed commented 2 years ago

breaking changes -- it certainly may -- I need that devops script so I can quickly find them :)