From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- source/compiler-core/slang-slice-allocator.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'source/compiler-core/slang-slice-allocator.cpp') diff --git a/source/compiler-core/slang-slice-allocator.cpp b/source/compiler-core/slang-slice-allocator.cpp index 49fd6a571..d24c05e9f 100644 --- a/source/compiler-core/slang-slice-allocator.cpp +++ b/source/compiler-core/slang-slice-allocator.cpp @@ -3,7 +3,8 @@ #include "../core/slang-blob.h" -namespace Slang { +namespace Slang +{ /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SliceUtil !!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -20,7 +21,7 @@ namespace Slang { return list; } -/* static */const char* SliceUtil::getTerminated(ISlangBlob* blob, TerminatedCharSlice& outSlice) +/* static */ const char* SliceUtil::getTerminated(ISlangBlob* blob, TerminatedCharSlice& outSlice) { const auto size = blob->getBufferSize(); if (size == 0) @@ -29,7 +30,7 @@ namespace Slang { return outSlice.begin(); } - // If there is a 0 at the end byte, we are zero terminated + // If there is a 0 at the end byte, we are zero terminated const char* chars = (const char*)blob->getBufferPointer(); if (chars[size - 1] == 0) { @@ -51,7 +52,9 @@ namespace Slang { return nullptr; } -/* static */TerminatedCharSlice SliceUtil::toTerminatedCharSlice(SliceAllocator& allocator, ISlangBlob* blob) +/* static */ TerminatedCharSlice SliceUtil::toTerminatedCharSlice( + SliceAllocator& allocator, + ISlangBlob* blob) { TerminatedCharSlice slice; if (SliceUtil::getTerminated(blob, slice)) @@ -59,25 +62,29 @@ namespace Slang { return slice; } const auto size = blob->getBufferSize(); - // We are out of options, we just have to allocate with zero termination which allocateString does - auto dst = allocator.getArena().allocateString((const char*)blob->getBufferPointer(), Count(size)); + // We are out of options, we just have to allocate with zero termination which allocateString + // does + auto dst = + allocator.getArena().allocateString((const char*)blob->getBufferPointer(), Count(size)); return TerminatedCharSlice(dst, Count(size)); } -/* static */TerminatedCharSlice SliceUtil::toTerminatedCharSlice(StringBuilder& storage, ISlangBlob* blob) +/* static */ TerminatedCharSlice SliceUtil::toTerminatedCharSlice( + StringBuilder& storage, + ISlangBlob* blob) { TerminatedCharSlice slice; if (SliceUtil::getTerminated(blob, slice)) { return slice; } - + const auto size = blob->getBufferSize(); auto chars = (const char*)blob->getBufferPointer(); storage.clear(); storage.append(UnownedStringSlice(chars, size)); - + return TerminatedCharSlice(storage.getBuffer(), Count(size)); } -- cgit v1.2.3