From af175d2e7e8b32f5519aac6992ba337aaaff6361 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 19 May 2020 17:16:37 +1000 Subject: Output debug memory stats in a nice table --- src/string_utils.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/string_utils.cc') diff --git a/src/string_utils.cc b/src/string_utils.cc index 3ce98940..2ae8ea6f 100644 --- a/src/string_utils.cc +++ b/src/string_utils.cc @@ -111,6 +111,16 @@ String replace(StringView str, StringView substr, StringView replacement) return res; } +String left_pad(StringView str, ColumnCount size, Codepoint c) +{ + return String(c, std::max(0_col, size - str.column_length())) + str.substr(0, size); +} + +String right_pad(StringView str, ColumnCount size, Codepoint c) +{ + return str.substr(0, size) + String(c, std::max(0_col, size - str.column_length())); +} + Optional str_to_int_ifp(StringView str) { bool negative = not str.empty() and str[0] == '-'; -- cgit v1.2.3