[demangler] Fix build breakage
The copy and pristine versions of Utility diverged and one didn't
include <algorithm>. As that's a rather large header, let's just open
code the comparisons.
Reviewed By:
Differential Revision: https://reviews.llvm.org/
GitOrigin-RevId: fbf7bbcb839929ff4eed89921191ed51a2a99777
diff --git a/src/demangle/Utility.h b/src/demangle/Utility.h
index 4ec821c..21e5efb 100644
--- a/src/demangle/Utility.h
+++ b/src/demangle/Utility.h
@@ -17,7 +17,6 @@
#define DEMANGLE_UTILITY_H
#include "StringView.h"
-#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
@@ -40,8 +39,11 @@
if (Need > BufferCapacity) {
// Avoid many reallocations during startup, with a bit of hysteresis.
constexpr size_t MinInitAlloc = 1024;
- Need = std::max(Need, MinInitAlloc);
- BufferCapacity = std::max(Need, BufferCapacity * 2);
+ if (Need < MinInitAlloc)
+ Need = MinInitAlloc;
+ BufferCapacity *= 2;
+ if (BufferCapacity < Need)
+ BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr)
std::terminate();