1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:15:07 +00:00

Everywhere: Avoid calling from_utf8 on FlyString or String

We already have a String :^)
This commit is contained in:
Shannon Booth 2023-12-09 09:24:41 +13:00 committed by Andreas Kling
parent 55ec1cbfb5
commit 6ce0d588ee
6 changed files with 18 additions and 30 deletions

View file

@ -256,7 +256,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpressi
Vector<NonnullRefPtr<AST::Node>> nodes;
for (auto& value_str : values) {
String removed = TRY(String::from_utf8(value_str));
String removed = value_str;
if (value_str.bytes_as_string_view().ends_with(suffix_str))
removed = TRY(removed.substring_from_byte_offset(0, value_str.bytes_as_string_view().length() - suffix_str.bytes_as_string_view().length()));
@ -288,7 +288,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_prefix(AST::ImmediateExpressi
Vector<NonnullRefPtr<AST::Node>> nodes;
for (auto& value_str : values) {
String removed = TRY(String::from_utf8(value_str));
String removed = value_str;
if (value_str.bytes_as_string_view().starts_with(prefix_str))
removed = TRY(removed.substring_from_byte_offset(prefix_str.bytes_as_string_view().length()));