[*] Improve alt-AuString allocator awareness

This commit is contained in:
Reece Wilson 2024-04-20 02:29:49 +01:00
parent 83f34b0c47
commit e7d9df3cab
17 changed files with 65 additions and 58 deletions

View File

@ -34,13 +34,19 @@ namespace Aurora::Console
time = 0;
}
inline ConsoleMessage(const AuString &prefix, const AuString &line) : prefix(prefix), line(line), color(EAnsiColor::eReset)
inline ConsoleMessage(const AuROString &prefix, const AuROString &line) :
prefix(prefix),
line(line),
color(EAnsiColor::eReset)
{
time = Time::CurrentClockMS();
tid = Threading::Threads::GetThreadId();
}
inline ConsoleMessage(const EAnsiColor color, const AuString &prefix, const AuString &line) : prefix(prefix), line(line), color(color)
inline ConsoleMessage(const EAnsiColor color, const AuROString &prefix, const AuROString &line) :
prefix(prefix),
line(line),
color(color)
{
time = Time::CurrentClockMS();
tid = Threading::Threads::GetThreadId();

View File

@ -51,7 +51,7 @@ namespace Aurora::Data
case EDataType::kTypeBoolean:
return value.primitive.boolean ? "true" : "false";
case EDataType::kTypeUUID:
return uuids::to_string(value.UUID);
return AuString(uuids::to_string(value.UUID));
case EDataType::kTypeVec3:
return AuToString(value.primitive.vec3[0]) + "." +
AuToString(value.primitive.vec3[1]) + "." +

View File

@ -29,7 +29,7 @@ namespace Aurora::HWInfo
#if defined(_AU_MASSIVE_CPUID)
return fmt::format("{4:#0{0}b} {3:#0{0}b} {2:#0{0}b} {1:#0{0}b}", sizeof(decltype(lower)) * 8, lower, upper, upper2, upper3);
#else
return fmt::format("{2:#0{0}b} {1:#0{0}b}", sizeof(decltype(lower)) * 8, lower, upper);
return AuString(fmt::format("{2:#0{0}b} {1:#0{0}b}", sizeof(decltype(lower)) * 8, lower, upper));
#endif
}

View File

@ -16,7 +16,8 @@
namespace Aurora::IO::NT
{
AUKN_SYM AuString ShareFileDescriptor(HANDLE hHandle);
AUKN_SYM void ShareFileDescriptorStop(const AuString &handle);
AUKN_SYM HANDLE ShareFileDescriptorAccept(const AuString &handle);
AUKN_SYM void ShareFileDescriptorStop(const AuROString &handle);
AUKN_SYM HANDLE ShareFileDescriptorAccept(const AuROString &handle);
}

View File

@ -35,7 +35,7 @@ namespace Aurora::Logging
#if defined(_AUHAS_FMT)
template<typename ... T>
inline void WriteLinef(AuUInt8 level, const AuString &tag, fmt::format_string<T...> msg, T&& ... args)
inline void WriteLinef(AuUInt8 level, const AuROString &tag, fmt::format_string<T...> msg, T&& ... args)
{
AU_DEBUG_MEMCRUNCH;
@ -50,7 +50,7 @@ namespace Aurora::Logging
}
template<typename ... T>
inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuString &tag, fmt::format_string<T...> msg, T&& ... args)
inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuROString &tag, fmt::format_string<T...> msg, T&& ... args)
{
AU_DEBUG_MEMCRUNCH;

View File

@ -25,11 +25,11 @@ namespace Aurora::Console
if (simple)
{
return fmt::format("{:%H:%M:%S}", localized);
return AuString(fmt::format("{:%H:%M:%S}", localized));
}
else
{
return fmt::format("{:%Y-%m-%d %H:%M:%S}", localized);
return AuString(fmt::format("{:%Y-%m-%d %H:%M:%S}", localized));
}
}
catch (...)
@ -84,22 +84,22 @@ namespace Aurora::Console
return this->ToPersistentString();
}
return fmt::format("[{}] {:<8} | {}",
StringifyTime(gRuntimeConfig.console.bStdOutShortTime),
GetWrappedTag(),
this->line);
return AuString(fmt::format("[{}] {:<8} | {}",
StringifyTime(gRuntimeConfig.console.bStdOutShortTime),
GetWrappedTag(),
this->line));
}
AuString ConsoleMessage::ToPersistentString() const
{
return fmt::format("[{}] {:<8} | {}",
StringifyTimeUTC(),
GetWrappedTag(),
this->line);
return AuString(fmt::format("[{}] {:<8} | {}",
StringifyTimeUTC(),
GetWrappedTag(),
this->line));
}
AuString ConsoleMessage::ToSimplified() const
{
return fmt::format("{:<9} {:<8} | {}", StringifyTime(true), GetWrappedTag(), this->line);
return AuString(fmt::format("{:<9} {:<8} | {}", StringifyTime(true), GetWrappedTag(), this->line));
}
}

View File

@ -1437,7 +1437,7 @@ namespace Aurora::Console::ConsoleTTY
void TTYConsole::WriteLine(int Y, const AuString &in)
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
RecordFunction(std::bind(&TTYConsole::WriteLine, this, Y, std::string(in)));
RecordFunction(std::bind(&TTYConsole::WriteLine, this, Y, AuString(in)));
#endif
if (in.empty())
@ -1486,7 +1486,7 @@ namespace Aurora::Console::ConsoleTTY
void TTYConsole::WriteBuffered(AuPair<AuUInt32, AuUInt32> pos, const AuString &in)
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
RecordFunction(std::bind(&TTYConsole::WriteBuffered, this, pos, std::string(in)));
RecordFunction(std::bind(&TTYConsole::WriteBuffered, this, pos, AuString(in)));
#endif
if (in.empty())
@ -1510,7 +1510,7 @@ namespace Aurora::Console::ConsoleTTY
void TTYConsole::WriteBufferedEx(AuPair<AuUInt32, AuUInt32> pos, EAnsiColor color, const AuString &in)
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
RecordFunction(std::bind(&TTYConsole::WriteBufferedEx, this, pos, color, std::string(in)));
RecordFunction(std::bind(&TTYConsole::WriteBufferedEx, this, pos, color, AuString(in)));
#endif
if (in.empty())

View File

@ -310,7 +310,7 @@ namespace Aurora::HWInfo
AuString CpuId::ToString() const
{
return fmt::format(
return AuString(fmt::format(
"FMA {}\t\tFSGSBASE {}\t\tCLFSH {}\t\t\tERMS {}{}"
"CMPXCHG16B {}\t\tAVX512PF {}\t\tMOVBE {}\t\t\tRTM {}{}"
"POPCNT {}\t\tAVX512ER {}\t\tMONITOR {}\t\t\tLAHF {}{}"
@ -337,7 +337,7 @@ namespace Aurora::HWInfo
AVX(), AVX512F(), BMI1(), INVPCID(), Aurora::Locale::NewLine(),
AVX2(), LZCNT(), HLE(), _3DNOWEXT(), Aurora::Locale::NewLine(),
MMX(), ADX(), BMI2(), _3DNOW()
);
));
}
AuUInt32 GetCPUIDAPICDCores()

View File

@ -88,7 +88,7 @@ namespace Aurora::IO::FS
utf8Root.pop_back();
}
return utf8Root;
return AuString(utf8Root);
}
AUKN_SYM AuResult<AuString> GetDeviceFromRoot(const AuString& root)
@ -112,7 +112,7 @@ namespace Aurora::IO::FS
// Only a subset of FIXED disks get a \\.\PhysicalDevice
// The path we currently have is usually good enough for whatever IOCTLs we need to send (the same cant be said for fixed disks tho)
// (they fail; they need the following...)
return utf8Root;
return AuString(utf8Root);
}
auto hFile = Win32Open(widePath.c_str(),
@ -153,7 +153,7 @@ namespace Aurora::IO::FS
if (extents.NumberOfDiskExtents)
{
return fmt::format("\\\\.\\PhysicalDrive{}", extents.Extents->DiskNumber);
return AuString(fmt::format("\\\\.\\PhysicalDrive{}", extents.Extents->DiskNumber));
}
else
{

View File

@ -89,7 +89,7 @@ namespace Aurora::IO::IPC
return val;
}
bool IPCHandle::FromString(const AuString &in)
bool IPCHandle::FromString(const AuROString &in)
{
AuString nextToken;
AuUInt nextInt;

View File

@ -83,7 +83,7 @@ namespace Aurora::IO::IPC
AuList<IPCValue> values;
bool FromString(const AuString &in);
bool FromString(const AuROString &in);
AuString ToString() const;

View File

@ -16,7 +16,7 @@ namespace Aurora::IO::NT
static AuThreads::ThreadUnique_t gServerThread {};
static const auto kDefaultMessageSize = 8192u;
static AuString GetIPCServerNameOfPid(AuUInt32 uPid)
static auto GetIPCServerNameOfPid(AuUInt32 uPid)
{
#if defined(AURORA_PLATFORM_WIN32)
return fmt::format("\\\\.\\pipe\\_HANDLESOF_{}", uPid);
@ -312,7 +312,7 @@ namespace Aurora::IO::NT
return handle.ToString();
}
AUKN_SYM void ShareFileDescriptorStop(const AuString &handle)
AUKN_SYM void ShareFileDescriptorStop(const AuROString &handle)
{
IPC::IPCHandle handle2;
if (!handle2.FromString(handle))
@ -331,7 +331,7 @@ namespace Aurora::IO::NT
}
}
AUKN_SYM HANDLE ShareFileDescriptorAccept(const AuString &handle)
AUKN_SYM HANDLE ShareFileDescriptorAccept(const AuROString &handle)
{
IPC::IPCHandle handle2;
HANDLE hHandle { INVALID_HANDLE_VALUE };

View File

@ -97,9 +97,9 @@ namespace Aurora::IO::Net
switch (this->ip)
{
case EIPProtocol::eIPProtocolV4:
return fmt::format("{}.{}.{}.{}", this->v4[0], this->v4[1], this->v4[2], this->v4[3]);
return AuString(fmt::format("{}.{}.{}.{}", this->v4[0], this->v4[1], this->v4[2], this->v4[3]));
case EIPProtocol::eIPProtocolV6:
return fmt::format("{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}", this->v6[0], this->v6[1], this->v6[2], this->v6[3], this->v6[4], this->v6[5], this->v6[6], this->v6[7]);
return AuString(fmt::format("{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}", this->v6[0], this->v6[1], this->v6[2], this->v6[3], this->v6[4], this->v6[5], this->v6[6], this->v6[7]));
}
return {};
}

View File

@ -204,7 +204,7 @@ namespace Aurora::IO::Net
AUKN_SYM AuString NetErrorToExtendedString(const NetError &error)
{
return fmt::format("error: {}, code: 0x{:x}, os: {}", NetErrorToString(error), error.osError, StringifyOSError(error.osError));
return AuString(fmt::format("error: {}, code: 0x{:x}, os: {}", NetErrorToString(error), error.osError, StringifyOSError(error.osError)));
}
AUKN_SYM AuString NetErrorToString(const NetError &error)

View File

@ -172,13 +172,13 @@ namespace Aurora::Locale
bool simple = time.mday == 0 && time.mon == 0 && time.year == 0;
if (simple)
{
return fmt::format("{:02}-{:02}-{:02}", time.hour, time.min, time.sec);
return AuString(fmt::format("{:02}-{:02}-{:02}", time.hour, time.min, time.sec));
}
else
{
// Hard-code ISO-8601 locale because, the Americans locale doesn't make any sense whatsoever, and east asia has the right idea
// EU users and burgers seethe... we normalize one sane standard to disambiguate this shit across locale boundaries
return fmt::format("{:04}-{:02}-{:02} {:02}-{:02}-{:02}", time.year, time.mon + 1, time.mday + 1, time.hour, time.min, time.sec);
return AuString(fmt::format("{:04}-{:02}-{:02} {:02}-{:02}-{:02}", time.year, time.mon + 1, time.mday + 1, time.hour, time.min, time.sec));
}
}
catch (...)
@ -194,9 +194,9 @@ namespace Aurora::Locale
{
AuString tz {};
auto tnorm = AuTime::NormalizeCivilTimezone(time, shift);
return fmt::format("{:04}-{:02}-{:02}T{:02}-{:02}-{:02}Z",
tnorm.year, tnorm.mon + 1, tnorm.mday + 1,
tnorm.hour, tnorm.min, tnorm.sec);
return AuString(fmt::format("{:04}-{:02}-{:02}T{:02}-{:02}-{:02}Z",
tnorm.year, tnorm.mon + 1, tnorm.mday + 1,
tnorm.hour, tnorm.min, tnorm.sec));
}
catch (...)
{
@ -211,9 +211,9 @@ namespace Aurora::Locale
{
AuString tz {};
auto tnorm = AuTime::NormalizeCivilTimezone(time, shift);
return fmt::format("{:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
tnorm.year, tnorm.mon + 1, tnorm.mday + 1,
tnorm.hour, tnorm.min, tnorm.sec);
return AuString(fmt::format("{:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
tnorm.year, tnorm.mon + 1, tnorm.mday + 1,
tnorm.hour, tnorm.min, tnorm.sec));
}
catch (...)
{

View File

@ -786,7 +786,7 @@ namespace Aurora::Parse
{
if (bZeroX)
{
auto str = fmt::format("{0:#X}", in);
auto str = AuString(fmt::format("{0:#X}", in));
if (str.size() > 2)
{
if (str[1] == 'X')
@ -802,7 +802,7 @@ namespace Aurora::Parse
}
else
{
return fmt::format("{:X}", in);
return AuString(fmt::format("{:X}", in));
}
}
@ -810,7 +810,7 @@ namespace Aurora::Parse
{
if (bZeroX)
{
auto str = fmt::format("{0:#X}", in);
auto str = AuString(fmt::format("{0:#X}", in));
if (str.size() > 2)
{
if (str[1] == 'X')
@ -826,7 +826,7 @@ namespace Aurora::Parse
}
else
{
return fmt::format("{:X}", in);
return AuString(fmt::format("{:X}", in));
}
}

View File

@ -137,12 +137,12 @@ namespace Aurora::Registry
{
if (read == EReadType::eStoreNew)
{
if (cacheDocument_.find(key) != cacheDocument_.end())
if (cacheDocument_.find(AuROString(key)) != cacheDocument_.end())
{
continue;
}
}
cacheDocument_[key] = value;
cacheDocument_[AuROString(key)] = value;
}
}
@ -157,7 +157,7 @@ namespace Aurora::Registry
{
AU_LOCK_GUARD(lock_->AsReadable());
auto itrObject = cacheDocument_.find(key);
auto itrObject = cacheDocument_.find(AuROString(key));
if (itrObject == cacheDocument_.end())
{
return false;
@ -199,7 +199,7 @@ namespace Aurora::Registry
bool FSRegistry::GetKeyLocked(const AuString &key, RegistryValue &value)
{
auto itrObject = cacheDocument_.find(key);
auto itrObject = cacheDocument_.find(AuROString(key));
if (itrObject == cacheDocument_.end())
{
return false;
@ -259,7 +259,7 @@ namespace Aurora::Registry
return false;
}
auto oldValueItr = cacheDocument_.find(key);
auto oldValueItr = cacheDocument_.find(AuROString(key));
bool hasOldValue = oldValueItr == cacheDocument_.end();
json oldValue = hasOldValue ? json{} : *oldValueItr;
@ -272,11 +272,11 @@ namespace Aurora::Registry
switch (writeMode_)
{
case EWriteMode::eWriteModeFileBuffer:
cacheDocument_[key] = object;
cacheDocument_[AuROString(key)] = object;
break;
case EWriteMode::eWriteModeFileStream:
cacheDocument_[key] = object;
currentStreamDocument_[key] = object;
cacheDocument_[AuROString(key)] = object;
currentStreamDocument_[AuROString(key)] = object;
Save();
break;
}
@ -292,7 +292,7 @@ namespace Aurora::Registry
for (const auto &change : changes_)
{
currentStreamDocument_[change] = cacheDocument_[change];
currentStreamDocument_[AuROString(change)] = cacheDocument_[AuROString(change)];
}
}
Save();
@ -305,7 +305,7 @@ namespace Aurora::Registry
for (const auto &[key, val] : cacheDocument_.items())
{
AuTryInsert(changes_, key);
AuTryInsert(changes_, AuString(key));
}
}