[llvm] 6580d8a - [Support] Don't include <algorithm> in MathExtras.h
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 08:53:52 PDT 2021
Author: Nico Weber
Date: 2021-04-16T11:53:31-04:00
New Revision: 6580d8a2b14d50b7e067dc86df6e5dd65703d147
URL: https://github.com/llvm/llvm-project/commit/6580d8a2b14d50b7e067dc86df6e5dd65703d147
DIFF: https://github.com/llvm/llvm-project/commit/6580d8a2b14d50b7e067dc86df6e5dd65703d147.diff
LOG: [Support] Don't include <algorithm> in MathExtras.h
MathExtras.h is indirectly included in over 98% of LLVM's
translation units. It currently expands to over 1MB of stuff,
over which far more than half is due to <algorithm>. Since not
using <algorithm> is slightly less code, do that.
No behavior change.
Differential Revision: https://reviews.llvm.org/D100656
Added:
Modified:
llvm/include/llvm/Support/MathExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index 640b3a11ce6c..10d4260a7eb1 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -14,7 +14,6 @@
#define LLVM_SUPPORT_MATHEXTRAS_H
#include "llvm/Support/Compiler.h"
-#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
@@ -793,7 +792,7 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) {
/// value of the result.
template <typename T>
std::enable_if_t<std::is_unsigned<T>::value, T> AbsoluteDifference(T X, T Y) {
- return std::max(X, Y) - std::min(X, Y);
+ return X > Y ? X - Y : Y - X;
}
/// Add two unsigned integers, X and Y, of type T. Clamp the result to the
More information about the llvm-commits
mailing list