mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 20:37:35 +00:00
AK+Userland: Remove nullability feature for the ByteBuffer type
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
This commit is contained in:
parent
c4d0b0cd6b
commit
53d0150827
16 changed files with 12 additions and 36 deletions
|
@ -563,11 +563,6 @@ int HexEditor::find_and_highlight(ByteBuffer& needle, int start)
|
|||
if (m_buffer.is_empty())
|
||||
return -1;
|
||||
|
||||
if (needle.is_null()) {
|
||||
dbgln("needle is null");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto raw_offset = memmem(m_buffer.data() + start, m_buffer.size(), needle.data(), needle.size());
|
||||
if (raw_offset == NULL)
|
||||
return -1;
|
||||
|
|
|
@ -189,7 +189,7 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar)
|
|||
}));
|
||||
|
||||
edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find-next.png"), [&](const GUI::Action&) {
|
||||
if (m_search_text.is_empty() || m_search_buffer.is_empty() || m_search_buffer.is_null()) {
|
||||
if (m_search_text.is_empty() || m_search_buffer.is_empty()) {
|
||||
GUI::MessageBox::show(window(), "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ const char* IODevice::error_string() const
|
|||
int IODevice::read(u8* buffer, int length)
|
||||
{
|
||||
auto read_buffer = read(length);
|
||||
if (read_buffer.is_null())
|
||||
return 0;
|
||||
memcpy(buffer, read_buffer.data(), length);
|
||||
return read_buffer.size();
|
||||
}
|
||||
|
@ -151,8 +149,6 @@ ByteBuffer IODevice::read_all()
|
|||
}
|
||||
data.append((const u8*)read_buffer, nread);
|
||||
}
|
||||
if (data.is_empty())
|
||||
return {};
|
||||
return ByteBuffer::copy(data.data(), data.size());
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void Job::on_socket_connected()
|
|||
auto read_size = 64 * KiB;
|
||||
|
||||
auto payload = receive(read_size);
|
||||
if (!payload) {
|
||||
if (payload.is_empty()) {
|
||||
if (eof()) {
|
||||
finish_up();
|
||||
return IterationDecision::Break;
|
||||
|
|
|
@ -283,7 +283,7 @@ void Job::on_socket_connected()
|
|||
}
|
||||
|
||||
auto payload = receive(read_size);
|
||||
if (!payload) {
|
||||
if (payload.is_empty()) {
|
||||
if (eof()) {
|
||||
finish_up();
|
||||
return IterationDecision::Break;
|
||||
|
|
|
@ -474,9 +474,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer)
|
|||
}
|
||||
break;
|
||||
case Finished:
|
||||
if (m_context.cached_handshake) {
|
||||
m_context.cached_handshake.clear();
|
||||
}
|
||||
m_context.cached_handshake.clear();
|
||||
if (m_context.handshake_messages[10] >= 1) {
|
||||
dbgln("unexpected finished message");
|
||||
payload_res = (i8)Error::UnexpectedMessage;
|
||||
|
|
|
@ -431,7 +431,7 @@ public:
|
|||
if (type != CSS::Selector::SimpleSelector::Type::Universal) {
|
||||
while (is_valid_selector_char(peek()))
|
||||
buffer.append(consume_one());
|
||||
PARSE_VERIFY(!buffer.is_null());
|
||||
PARSE_VERIFY(!buffer.is_empty());
|
||||
}
|
||||
|
||||
auto value = String::copy(buffer);
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
bool is_failed() const { return m_failed; }
|
||||
const String& error() const { return m_error; }
|
||||
|
||||
bool has_encoded_data() const { return !m_encoded_data.is_null(); }
|
||||
bool has_encoded_data() const { return !m_encoded_data.is_empty(); }
|
||||
|
||||
const URL& url() const { return m_request.url(); }
|
||||
const ByteBuffer& encoded_data() const { return m_encoded_data; }
|
||||
|
|
|
@ -47,7 +47,7 @@ void XMLHttpRequest::fire_progress_event(const String& event_name, u64 transmitt
|
|||
|
||||
String XMLHttpRequest::response_text() const
|
||||
{
|
||||
if (m_response_object.is_null())
|
||||
if (m_response_object.is_empty())
|
||||
return {};
|
||||
return String::copy(m_response_object);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ int perform_copy(const String& source, const String& destination)
|
|||
while (true) {
|
||||
print_progress();
|
||||
auto buffer = source_file.read(65536);
|
||||
if (buffer.is_null())
|
||||
if (buffer.is_empty())
|
||||
break;
|
||||
if (!destination_file.write(buffer)) {
|
||||
report_warning(String::formatted("Failed to write to destination file: {}", destination_file.error_string()));
|
||||
|
|
|
@ -168,7 +168,7 @@ Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, DNSRecordType record
|
|||
}
|
||||
|
||||
auto buffer = receive(1024);
|
||||
if (!buffer)
|
||||
if (buffer.is_empty())
|
||||
return {};
|
||||
auto optional_packet = DNSPacket::from_raw_packet(buffer.data(), buffer.size());
|
||||
if (!optional_packet.has_value()) {
|
||||
|
|
|
@ -41,7 +41,7 @@ void Client::start()
|
|||
{
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
auto raw_request = m_socket->read_all();
|
||||
if (raw_request.is_null()) {
|
||||
if (raw_request.is_empty()) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,8 @@ int parse_args(int argc, char** argv, Vector<String>& files, DuOption& du_option
|
|||
auto file = Core::File::construct(exclude_from);
|
||||
bool success = file->open(Core::OpenMode::ReadOnly);
|
||||
VERIFY(success);
|
||||
if (const auto buff = file->read_all()) {
|
||||
const auto buff = file->read_all();
|
||||
if (!buff.is_empty()) {
|
||||
String patterns = String::copy(buff, Chomp);
|
||||
du_option.excluded_patterns.append(patterns.split('\n'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue