From 4db96bc758445f4d1daa63efb48607576aff8561 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sat, 16 Jul 2016 17:55:18 -0700 Subject: [PATCH] Use simple if-statement-based min/max functions in hot code. Again, for whatever reason this is notably faster than the stdlib min/max functions. --- src/bbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bbox.rs b/src/bbox.rs index 7af6478..000432c 100644 --- a/src/bbox.rs +++ b/src/bbox.rs @@ -4,7 +4,7 @@ use std; use std::ops::{BitOr, BitOrAssign}; use std::iter::Iterator; -use math::{Point, Matrix4x4}; +use math::{Point, Matrix4x4, fast_minf32, fast_maxf32}; use lerp::{lerp, lerp_slice, Lerp}; use ray::AccelRay; @@ -52,7 +52,7 @@ impl BBox { let hitt1 = far_t.h_min() * BBOX_MAXT_ADJUST; // Did we hit? - return hitt0.max(0.0) <= hitt1.min(ray.max_t); + return fast_maxf32(hitt0, 0.0) <= fast_minf32(hitt1, ray.max_t); } // Creates a new BBox transformed into a different space.