소스 검색

AK: Rename `Stream::format()` to `Stream::write_formatted()`

This brings the function name in line with how we usually name those
functions, which is with a `read_` or `write_` prefix depending on what
they do.

While at it, make the internal `_impl` function private and not-virtual,
since there is no good reason to ever override that function.
Tim Schumacher 2 년 전
부모
커밋
5e7c838160
3개의 변경된 파일8개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      AK/Stream.cpp
  2. 5 4
      AK/Stream.h
  3. 2 2
      Userland/Libraries/LibJS/Print.cpp

+ 1 - 1
AK/Stream.cpp

@@ -98,7 +98,7 @@ ErrorOr<void> Stream::write_until_depleted(ReadonlyBytes buffer)
     return {};
 }
 
-ErrorOr<void> Stream::format_impl(StringView fmtstr, TypeErasedFormatParams& parameters)
+ErrorOr<void> Stream::write_formatted_impl(StringView fmtstr, TypeErasedFormatParams& parameters)
 {
     StringBuilder builder;
     TRY(vformat(builder, fmtstr, parameters));

+ 5 - 4
AK/Stream.h

@@ -77,13 +77,11 @@ public:
         return write_until_depleted({ &value, sizeof(value) });
     }
 
-    virtual ErrorOr<void> format_impl(StringView, TypeErasedFormatParams&);
-
     template<typename... Parameters>
-    ErrorOr<void> format(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
+    ErrorOr<void> write_formatted(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
     {
         VariadicFormatParams<AllowDebugOnlyFormatters::No, Parameters...> variadic_format_params { parameters... };
-        TRY(format_impl(fmtstr.view(), variadic_format_params));
+        TRY(write_formatted_impl(fmtstr.view(), variadic_format_params));
         return {};
     }
 
@@ -108,6 +106,9 @@ protected:
     /// content size to be in order to reduce allocations (does not affect
     /// actual reading).
     ErrorOr<ByteBuffer> read_until_eof_impl(size_t block_size, size_t expected_file_size = 0);
+
+private:
+    ErrorOr<void> write_formatted_impl(StringView, TypeErasedFormatParams&);
 };
 
 enum class SeekMode {

+ 2 - 2
Userland/Libraries/LibJS/Print.cpp

@@ -141,9 +141,9 @@ ErrorOr<void> js_out(JS::PrintContext& print_context, CheckedFormatString<Args..
 {
     if (print_context.strip_ansi) {
         auto format_string_without_ansi = TRY(strip_ansi(format_string.view()));
-        TRY(print_context.stream.format(format_string_without_ansi, args...));
+        TRY(print_context.stream.write_formatted(format_string_without_ansi, args...));
     } else {
-        TRY(print_context.stream.format(format_string.view(), args...));
+        TRY(print_context.stream.write_formatted(format_string.view(), args...));
     }
 
     return {};