[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/
This commit is contained in:
Nathan Sidwell 2022-02-16 08:03:24 -08:00
parent 5781839f7a
commit fbf7bbcb83
2 changed files with 10 additions and 5 deletions

View File

@ -17,7 +17,6 @@
#define DEMANGLE_UTILITY_H #define DEMANGLE_UTILITY_H
#include "StringView.h" #include "StringView.h"
#include <algorithm>
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
@ -40,8 +39,11 @@ class OutputBuffer {
if (Need > BufferCapacity) { if (Need > BufferCapacity) {
// Avoid many reallocations during startup, with a bit of hysteresis. // Avoid many reallocations during startup, with a bit of hysteresis.
constexpr size_t MinInitAlloc = 1024; constexpr size_t MinInitAlloc = 1024;
Need = std::max(Need, MinInitAlloc); if (Need < MinInitAlloc)
BufferCapacity = std::max(Need, BufferCapacity * 2); Need = MinInitAlloc;
BufferCapacity *= 2;
if (BufferCapacity < Need)
BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity)); Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr) if (Buffer == nullptr)
std::terminate(); std::terminate();

View File

@ -39,8 +39,11 @@ class OutputBuffer {
if (Need > BufferCapacity) { if (Need > BufferCapacity) {
// Avoid many reallocations during startup, with a bit of hysteresis. // Avoid many reallocations during startup, with a bit of hysteresis.
constexpr size_t MinInitAlloc = 1024; constexpr size_t MinInitAlloc = 1024;
Need = std::max(Need, MinInitAlloc); if (Need < MinInitAlloc)
BufferCapacity = std::max(Need, BufferCapacity * 2); Need = MinInitAlloc;
BufferCapacity *= 2;
if (BufferCapacity < Need)
BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity)); Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr) if (Buffer == nullptr)
std::terminate(); std::terminate();