Преглед изворни кода

LibRegex: Convert String::format() => String::formatted()

Andreas Kling пре 4 година
родитељ
комит
c68dcf45b6

+ 1 - 1
Userland/Libraries/LibRegex/RegexByteCode.cpp

@@ -692,7 +692,7 @@ ALWAYS_INLINE void OpCode_Compare::compare_character_range(const MatchInput& inp
 
 const String OpCode_Compare::arguments_string() const
 {
-    return String::format("argc=%lu, args=%lu ", arguments_count(), arguments_size());
+    return String::formatted("argc={}, args={} ", arguments_count(), arguments_size());
 }
 
 const Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput> input) const

+ 9 - 9
Userland/Libraries/LibRegex/RegexByteCode.h

@@ -537,7 +537,7 @@ public:
 
     const String to_string() const
     {
-        return String::format("[0x%02X] %s", (int)opcode_id(), name(opcode_id()));
+        return String::formatted("[0x{:02X}] {}", (int)opcode_id(), name(opcode_id()));
     }
 
     virtual const String arguments_string() const = 0;
@@ -623,7 +623,7 @@ public:
     ALWAYS_INLINE ssize_t offset() const { return argument(0); }
     const String arguments_string() const override
     {
-        return String::format("offset=%zd [&%zu]", offset(), state().instruction_position + size() + offset());
+        return String::formatted("offset={} [&{}]", offset(), state().instruction_position + size() + offset());
     }
 };
 
@@ -639,7 +639,7 @@ public:
     ALWAYS_INLINE ssize_t offset() const { return argument(0); }
     const String arguments_string() const override
     {
-        return String::format("offset=%zd [&%zu], sp: %zu", offset(), state().instruction_position + size() + offset(), state().string_position);
+        return String::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
     }
 };
 
@@ -655,7 +655,7 @@ public:
     ALWAYS_INLINE ssize_t offset() const { return argument(0); }
     const String arguments_string() const override
     {
-        return String::format("offset=%zd [&%zu], sp: %zu", offset(), state().instruction_position + size() + offset(), state().string_position);
+        return String::formatted("offset={} [&{}], sp: {}", offset(), state().instruction_position + size() + offset(), state().string_position);
     }
 };
 
@@ -694,7 +694,7 @@ public:
     ALWAYS_INLINE size_t size() const override { return 2; }
     ALWAYS_INLINE size_t arguments_count() const { return 1; }
     ALWAYS_INLINE BoundaryCheckType type() const { return static_cast<BoundaryCheckType>(argument(0)); }
-    const String arguments_string() const override { return String::format("kind=%lu (%s)", (long unsigned int)argument(0), boundary_check_type_name(type())); }
+    const String arguments_string() const override { return String::formatted("kind={} ({})", (long unsigned int)argument(0), boundary_check_type_name(type())); }
 };
 
 class OpCode_SaveLeftCaptureGroup final : public OpCode {
@@ -707,7 +707,7 @@ public:
     ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::SaveLeftCaptureGroup; }
     ALWAYS_INLINE size_t size() const override { return 2; }
     ALWAYS_INLINE size_t id() const { return argument(0); }
-    const String arguments_string() const override { return String::format("id=%lu", id()); }
+    const String arguments_string() const override { return String::formatted("id={}", id()); }
 };
 
 class OpCode_SaveRightCaptureGroup final : public OpCode {
@@ -720,7 +720,7 @@ public:
     ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::SaveRightCaptureGroup; }
     ALWAYS_INLINE size_t size() const override { return 2; }
     ALWAYS_INLINE size_t id() const { return argument(0); }
-    const String arguments_string() const override { return String::format("id=%lu", id()); }
+    const String arguments_string() const override { return String::formatted("id={}", id()); }
 };
 
 class OpCode_SaveLeftNamedCaptureGroup final : public OpCode {
@@ -736,7 +736,7 @@ public:
     ALWAYS_INLINE size_t length() const { return argument(1); }
     const String arguments_string() const override
     {
-        return String::format("name=%s, length=%lu", name().to_string().characters(), length());
+        return String::formatted("name={}, length={}", name(), length());
     }
 };
 
@@ -753,7 +753,7 @@ public:
     ALWAYS_INLINE size_t length() const { return argument(1); }
     const String arguments_string() const override
     {
-        return String::format("name=%s, length=%zu", name().to_string().characters(), length());
+        return String::formatted("name={}, length={}", name(), length());
     }
 };
 

+ 2 - 2
Userland/Libraries/LibRegex/RegexDebug.h

@@ -30,7 +30,7 @@
 #include "LibRegex/RegexMatcher.h"
 #include <AK/Debug.h>
 
-#if REGEX_DEBUG
+#if !REGEX_DEBUG
 
 namespace regex {
 
@@ -87,7 +87,7 @@ public:
             recursion,
             opcode.to_string().characters(),
             opcode.arguments_string().characters(),
-            String::format("ip: %3lu,   sp: %3lu", state.instruction_position, state.string_position).characters(),
+            String::formatted("ip: {:3},   sp: {:3}", state.instruction_position, state.string_position).characters(),
             newline ? "\n" : "");
 
         if (newline && is<OpCode_Compare>(opcode)) {