From d6eeb14216f77cda6d089f737b2b21dcb30e326c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 24 Oct 2016 14:45:40 +0200 Subject: [PATCH] Avoid unnecessary ldexp() and pow() calls Parse times for some large .obj files (without asan): File A File B File C Before 1239ms 294ms 271ms After 1037ms 203ms 190ms --- tiny_obj_loader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h index f043628..b62321b 100644 --- a/tiny_obj_loader.h +++ b/tiny_obj_loader.h @@ -472,8 +472,8 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) { } assemble: - *result = - (sign == '+' ? 1 : -1) * ldexp(mantissa * pow(5.0, exponent), exponent); + *result = (sign == '+' ? 1 : -1) * + (exponent ? ldexp(mantissa * pow(5.0, exponent), exponent) : mantissa); return true; fail: return false;