Skip to content

Commit

Permalink
Remove unused code from url_utf.cpp and url_utf.h
Browse files Browse the repository at this point in the history
Also remove the dependency on buffer.h in url_utf.h.
  • Loading branch information
rmisev committed Sep 5, 2024
1 parent 687d15d commit 2f2a284
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
19 changes: 8 additions & 11 deletions include/upa/url_utf.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
#ifndef UPA_URL_UTF_H
#define UPA_URL_UTF_H

#include "buffer.h"
#include "url_result.h"
#include <cstddef>
#include <cstdint> // uint8_t, uint32_t
#include <string>

Expand All @@ -27,13 +25,10 @@ class url_utf {
template <class Output, void appendByte(unsigned char, Output&)>
static void append_utf8(uint32_t code_point, Output& output);

template <std::size_t N>
static void append_utf16(uint32_t code_point, simple_buffer<char16_t, N>& 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<char16_t>& output);
#if 0 // UNUSED
template <class Output>
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);
Expand Down Expand Up @@ -241,20 +236,22 @@ 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 <std::size_t N>
inline void url_utf::append_utf16(uint32_t code_point, simple_buffer<char16_t, N>& output) {
template <class Output>
inline void url_utf::append_utf16(uint32_t code_point, Output& output) {
if (code_point <= 0xffff) {
output.push_back(static_cast<char16_t>(code_point));
} else {
output.push_back(static_cast<char16_t>((code_point >> 10) + 0xd7c0));
output.push_back(static_cast<char16_t>((code_point & 0x3ff) | 0xdc00));
}
}
#endif


} // namespace upa
Expand Down
10 changes: 0 additions & 10 deletions src/url_utf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

namespace upa {

bool url_utf::convert_utf8_to_utf16(const char* first, const char* last, simple_buffer<char16_t>& 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 <typename CharT>
inline std::string to_utf8_stringT(const CharT* first, const CharT* last) {
std::string output;
Expand Down

0 comments on commit 2f2a284

Please sign in to comment.