mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +00:00
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
This commit is contained in:
parent
15f4043a7a
commit
fdfda6dec2
Notes:
sideshowbarker
2024-07-19 05:41:49 +09:00
Author: https://github.com/awesomekling
Commit: fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -266,18 +266,17 @@ static bool parse_html_document(const StringView& html, Document& document, Pare
|
|||
}
|
||||
|
||||
if (j < 7) { // We found ; char
|
||||
bool ok;
|
||||
u32 codepoint;
|
||||
Optional<u32> codepoint;
|
||||
String str_code_point = html.substring_view(i + 2, j - 2);
|
||||
if (str_code_point.starts_with('x')) {
|
||||
String str = str_code_point.substring(1, str_code_point.length() - 1);
|
||||
codepoint = AK::StringUtils::convert_to_uint_from_hex(str, ok);
|
||||
codepoint = AK::StringUtils::convert_to_uint_from_hex(str);
|
||||
} else {
|
||||
codepoint = str_code_point.to_uint(ok);
|
||||
codepoint = str_code_point.to_uint();
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
Vector<char> bytes = codepoint_to_bytes(codepoint);
|
||||
if (codepoint.has_value()) {
|
||||
Vector<char> bytes = codepoint_to_bytes(codepoint.value());
|
||||
if (bytes.size() > 0) {
|
||||
for (size_t i = 0; i < bytes.size(); i++) {
|
||||
text_buffer.append(bytes.at(i));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue