core/irrt: use __builtin_strlen

This commit is contained in:
lyken 2024-08-26 15:24:50 +08:00
parent 77bf76dbdd
commit 925bf47f4e
No known key found for this signature in database
GPG Key ID: 3BD5FC6AC8325DD8
2 changed files with 3 additions and 24 deletions

View File

@ -1,20 +0,0 @@
#pragma once
#include <irrt/int_types.hpp>
namespace cstr
{
/**
* @brief Implementation of `strlen()`.
*/
uint32_t length(const char *str)
{
uint32_t length = 0;
while (*str != '\0')
{
length++;
str++;
}
return length;
}
} // namespace cstr

View File

@ -1,7 +1,6 @@
#pragma once
#include <irrt/cslice.hpp>
#include <irrt/cstr_util.hpp>
#include <irrt/int_types.hpp>
/**
@ -53,11 +52,11 @@ void _raise_exception_helper(ExceptionId id, const char *filename, int32_t line,
{
Exception<SizeT> e = {
.id = id,
.filename = {.base = (uint8_t *)filename, .len = (int32_t)cstr::length(filename)},
.filename = {.base = (uint8_t *)filename, .len = __builtin_strlen(filename)},
.line = line,
.column = 0,
.function = {.base = (uint8_t *)function, .len = (int32_t)cstr::length(function)},
.msg = {.base = (uint8_t *)msg, .len = (int32_t)cstr::length(msg)},
.function = {.base = (uint8_t *)function, .len = __builtin_strlen(function)},
.msg = {.base = (uint8_t *)msg, .len = __builtin_strlen(msg)},
};
e.params[0] = param0;
e.params[1] = param1;