Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solvespace/solvespace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7d181f0d0fbd
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a9ec64488988
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on May 13, 2019

  1. Small performance optimization in Vector::Equals.

    This function showed up surprisingly high on a CPU time profile
    when the GUI was unresponsive "doing things". Removed a duplicated
    difference in the not-equal case, and switched to abs and a single compare
    instead of two compares with a negation. It seems to have moved the
    function further down in the profile.
    rpavlik authored and whitequark committed May 13, 2019
    Copy the full SHA
    a9ec644 View commit details
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/util.cpp
9 changes: 5 additions & 4 deletions src/util.cpp
Original file line number Diff line number Diff line change
@@ -441,11 +441,12 @@ double Vector::Element(int i) const {

bool Vector::Equals(Vector v, double tol) const {
// Quick axis-aligned tests before going further
double dx = v.x - x; if(dx < -tol || dx > tol) return false;
double dy = v.y - y; if(dy < -tol || dy > tol) return false;
double dz = v.z - z; if(dz < -tol || dz > tol) return false;
const Vector dv = this->Minus(v);
if (std::abs(dv.x) > tol) return false;
if (std::abs(dv.y) > tol) return false;
if (std::abs(dv.z) > tol) return false;

return (this->Minus(v)).MagSquared() < tol*tol;
return dv.MagSquared() < tol*tol;
}

bool Vector::EqualsExactly(Vector v) const {