diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-11 17:32:29 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | 3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch) | |
tree | 152c7a187c98184d58bf91a326357e0af435edcf /Userland/Libraries/LibRegex/RegexByteCode.cpp | |
parent | e5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff) | |
download | serenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip |
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).
No functional changes.
Diffstat (limited to 'Userland/Libraries/LibRegex/RegexByteCode.cpp')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexByteCode.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp index 4212c10b89..be5f5a8533 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.cpp +++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp @@ -14,94 +14,94 @@ namespace regex { -char const* OpCode::name(OpCodeId opcode_id) +StringView OpCode::name(OpCodeId opcode_id) { switch (opcode_id) { #define __ENUMERATE_OPCODE(x) \ case OpCodeId::x: \ - return #x; + return #x##sv; ENUMERATE_OPCODES #undef __ENUMERATE_OPCODE default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } -char const* OpCode::name() const +StringView OpCode::name() const { return name(opcode_id()); } -char const* execution_result_name(ExecutionResult result) +StringView execution_result_name(ExecutionResult result) { switch (result) { #define __ENUMERATE_EXECUTION_RESULT(x) \ case ExecutionResult::x: \ - return #x; + return #x##sv; ENUMERATE_EXECUTION_RESULTS #undef __ENUMERATE_EXECUTION_RESULT default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } -char const* opcode_id_name(OpCodeId opcode) +StringView opcode_id_name(OpCodeId opcode) { switch (opcode) { #define __ENUMERATE_OPCODE(x) \ case OpCodeId::x: \ - return #x; + return #x##sv; ENUMERATE_OPCODES #undef __ENUMERATE_OPCODE default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } -char const* boundary_check_type_name(BoundaryCheckType ty) +StringView boundary_check_type_name(BoundaryCheckType ty) { switch (ty) { #define __ENUMERATE_BOUNDARY_CHECK_TYPE(x) \ case BoundaryCheckType::x: \ - return #x; + return #x##sv; ENUMERATE_BOUNDARY_CHECK_TYPES #undef __ENUMERATE_BOUNDARY_CHECK_TYPE default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } -char const* character_compare_type_name(CharacterCompareType ch_compare_type) +StringView character_compare_type_name(CharacterCompareType ch_compare_type) { switch (ch_compare_type) { #define __ENUMERATE_CHARACTER_COMPARE_TYPE(x) \ case CharacterCompareType::x: \ - return #x; + return #x##sv; ENUMERATE_CHARACTER_COMPARE_TYPES #undef __ENUMERATE_CHARACTER_COMPARE_TYPE default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } -static char const* character_class_name(CharClass ch_class) +static StringView character_class_name(CharClass ch_class) { switch (ch_class) { #define __ENUMERATE_CHARACTER_CLASS(x) \ case CharClass::x: \ - return #x; + return #x##sv; ENUMERATE_CHARACTER_CLASSES #undef __ENUMERATE_CHARACTER_CLASS default: VERIFY_NOT_REACHED(); - return "<Unknown>"; + return "<Unknown>"sv; } } |