From 925bf47f4e9df76709d250c65d9bed1acc75f0fd Mon Sep 17 00:00:00 2001 From: lyken Date: Mon, 26 Aug 2024 15:24:50 +0800 Subject: [PATCH] core/irrt: use __builtin_strlen --- nac3core/irrt/irrt/cstr_util.hpp | 20 -------------------- nac3core/irrt/irrt/exception.hpp | 7 +++---- 2 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 nac3core/irrt/irrt/cstr_util.hpp diff --git a/nac3core/irrt/irrt/cstr_util.hpp b/nac3core/irrt/irrt/cstr_util.hpp deleted file mode 100644 index cf6ed34d..00000000 --- a/nac3core/irrt/irrt/cstr_util.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -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 \ No newline at end of file diff --git a/nac3core/irrt/irrt/exception.hpp b/nac3core/irrt/irrt/exception.hpp index 22eea6ae..9b1091fa 100644 --- a/nac3core/irrt/irrt/exception.hpp +++ b/nac3core/irrt/irrt/exception.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include /** @@ -53,11 +52,11 @@ void _raise_exception_helper(ExceptionId id, const char *filename, int32_t line, { Exception 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;