From ec407bbd7f8af2dcda4bc64686d0bb3239c285d7 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 16 Jul 2014 12:19:12 -0700 Subject: [PATCH] Don't use std::min/max in mid() VC++'s optimizer completely falls down on it for whatever reason. --- src/utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index 7e6a171ee..f09687ae9 100644 --- a/src/utils.h +++ b/src/utils.h @@ -80,7 +80,9 @@ template T tabs(T x) { return x < 0 ? -x : x; } /// Get the middle value of a, b, and c (i.e. clamp b to [a,c]) /// @precondition a <= c -template inline T mid(T a, T b, T c) { return std::max(a, std::min(b, c)); } +template inline T mid(T a, T b, T c) { + return a > b ? a : (b > c ? c : b); +} /// Get the text contents of the clipboard, or empty string on failure std::string GetClipboard();