mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:37:35 +00:00
Make kernel build with clang.
It's a bit faster than g++ and seems to generate perfectly fine code. The kernel is also roughly 10% smaller(!)
This commit is contained in:
parent
7b3b5f745f
commit
ebf308d413
10 changed files with 40 additions and 27 deletions
|
@ -29,9 +29,7 @@ static inline size_t allocationSizeForStringImpl(size_t length)
|
|||
|
||||
RetainPtr<StringImpl> StringImpl::createUninitialized(size_t length, char*& buffer)
|
||||
{
|
||||
if (!length)
|
||||
return theEmptyStringImpl();
|
||||
|
||||
ASSERT(length);
|
||||
void* slot = kmalloc(allocationSizeForStringImpl(length));
|
||||
if (!slot)
|
||||
return nullptr;
|
||||
|
@ -52,6 +50,8 @@ RetainPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Sho
|
|||
|
||||
char* buffer;
|
||||
auto newStringImpl = createUninitialized(length, buffer);
|
||||
if (!newStringImpl)
|
||||
return nullptr;
|
||||
memcpy(buffer, cstring, length * sizeof(char));
|
||||
|
||||
if (shouldChomp && buffer[length - 1] == '\n') {
|
||||
|
@ -108,6 +108,8 @@ RetainPtr<StringImpl> StringImpl::toLowercase() const
|
|||
slowPath:
|
||||
char* buffer;
|
||||
auto lowercased = createUninitialized(m_length, buffer);
|
||||
if (!lowercased)
|
||||
return nullptr;
|
||||
for (size_t i = 0; i < m_length; ++i)
|
||||
buffer[i] = toASCIILowercase(m_characters[i]);
|
||||
|
||||
|
@ -128,6 +130,8 @@ RetainPtr<StringImpl> StringImpl::toUppercase() const
|
|||
slowPath:
|
||||
char* buffer;
|
||||
auto uppercased = createUninitialized(m_length, buffer);
|
||||
if (!uppercased)
|
||||
return nullptr;
|
||||
for (size_t i = 0; i < m_length; ++i)
|
||||
buffer[i] = toASCIIUppercase(m_characters[i]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue