mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
LibJS: Emit StringViews for ErrorType instances
This removes the need for calculating each string's length during ErrorType use at the cost of storing it within the binary.
This commit is contained in:
parent
6c46383e23
commit
3d656ba600
2 changed files with 6 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
|||
namespace JS {
|
||||
|
||||
#define __ENUMERATE_JS_ERROR(name, message) \
|
||||
const ErrorType ErrorType::name = ErrorType(message);
|
||||
const ErrorType ErrorType::name = ErrorType(message##sv);
|
||||
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
|
||||
#undef __ENUMERATE_JS_ERROR
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StringView.h>
|
||||
|
||||
#define JS_ENUMERATE_ERROR_TYPES(M) \
|
||||
M(ArrayMaxSize, "Maximum array size exceeded") \
|
||||
M(AccessorBadField, "Accessor descriptor's '{}' field must be a function or undefined") \
|
||||
|
@ -306,18 +308,18 @@ public:
|
|||
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
|
||||
#undef __ENUMERATE_JS_ERROR
|
||||
|
||||
char const* message() const
|
||||
StringView message() const
|
||||
{
|
||||
return m_message;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit ErrorType(char const* message)
|
||||
explicit ErrorType(StringView message)
|
||||
: m_message(message)
|
||||
{
|
||||
}
|
||||
|
||||
char const* m_message;
|
||||
StringView m_message;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue