mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibJS: Create exception messages as Strings
The JS::Error types all store their exception messages as a String. So by using ByteString, we hit the StringView constructor, and end up allocating the same string twice.
This commit is contained in:
parent
144e822de2
commit
c3f8202d0c
Notes:
sideshowbarker
2024-07-18 02:44:22 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/c3f8202d0ca Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/684
1 changed files with 7 additions and 1 deletions
|
@ -198,10 +198,16 @@ public:
|
|||
return JS::throw_completion(completion);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Completion throw_completion(ErrorType type)
|
||||
{
|
||||
return throw_completion<T>(String::from_utf8_without_validation(type.message().bytes()));
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
Completion throw_completion(ErrorType type, Args&&... args)
|
||||
{
|
||||
return throw_completion<T>(ByteString::formatted(type.message(), forward<Args>(args)...));
|
||||
return throw_completion<T>(MUST(String::formatted(type.message(), forward<Args>(args)...)));
|
||||
}
|
||||
|
||||
Value get_new_target();
|
||||
|
|
Loading…
Reference in a new issue