From 2f2a284bc13c970f83c6576fbcd99816600ab585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Thu, 5 Sep 2024 21:58:47 +0300 Subject: [PATCH] Remove unused code from url_utf.cpp and url_utf.h Also remove the dependency on buffer.h in url_utf.h. --- include/upa/url_utf.h | 19 ++++++++----------- src/url_utf.cpp | 10 ---------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/include/upa/url_utf.h b/include/upa/url_utf.h index ebc89f3b..b7c267af 100644 --- a/include/upa/url_utf.h +++ b/include/upa/url_utf.h @@ -6,9 +6,7 @@ #ifndef UPA_URL_UTF_H #define UPA_URL_UTF_H -#include "buffer.h" #include "url_result.h" -#include #include // uint8_t, uint32_t #include @@ -27,13 +25,10 @@ class url_utf { template static void append_utf8(uint32_t code_point, Output& output); - template - static void append_utf16(uint32_t code_point, simple_buffer& output); - - // Invalid utf-8 bytes sequences are replaced with 0xFFFD character. - // Returns false if input contains invalid utf-8 byte sequence, or - // true otherwise. - static bool convert_utf8_to_utf16(const char* first, const char* last, simple_buffer& output); +#if 0 // UNUSED + template + static void append_utf16(uint32_t code_point, Output& output); +#endif // Convert to utf-8 string static std::string to_utf8_string(const char16_t* first, const char16_t* last); @@ -241,13 +236,14 @@ inline void url_utf::append_utf8(uint32_t code_point, Output& output) { } } +#if 0 // UNUSED // Modified version of the U16_APPEND_UNSAFE macro in utf16.h from ICU // // It converts code_point to UTF-16 code units sequence and appends to output. // It assumes a valid code point (https://infra.spec.whatwg.org/#scalar-value). -template -inline void url_utf::append_utf16(uint32_t code_point, simple_buffer& output) { +template +inline void url_utf::append_utf16(uint32_t code_point, Output& output) { if (code_point <= 0xffff) { output.push_back(static_cast(code_point)); } else { @@ -255,6 +251,7 @@ inline void url_utf::append_utf16(uint32_t code_point, simple_buffer((code_point & 0x3ff) | 0xdc00)); } } +#endif } // namespace upa diff --git a/src/url_utf.cpp b/src/url_utf.cpp index 24af84e6..68c3d48c 100644 --- a/src/url_utf.cpp +++ b/src/url_utf.cpp @@ -8,16 +8,6 @@ namespace upa { -bool url_utf::convert_utf8_to_utf16(const char* first, const char* last, simple_buffer& output) { - bool success = true; - for (auto it = first; it < last;) { - const auto cp_res = read_utf_char(it, last); - append_utf16(cp_res.value, output); - success &= cp_res.result; - } - return success; -} - template inline std::string to_utf8_stringT(const CharT* first, const CharT* last) { std::string output;