mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
AK: Remove unnecessary casts to size_t, after Vector changes
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
This commit is contained in:
parent
fee20bd8de
commit
22d0a6d92f
15 changed files with 60 additions and 57 deletions
|
@ -47,7 +47,7 @@ HashMap<pid_t, Core::ProcessStatistics> ProcessStatisticsReader::get_all()
|
|||
HashMap<pid_t, Core::ProcessStatistics> map;
|
||||
|
||||
auto file_contents = file->read_all();
|
||||
auto json = JsonValue::from_string({ file_contents.data(), (size_t)file_contents.size() });
|
||||
auto json = JsonValue::from_string(file_contents);
|
||||
json.as_array().for_each([&](auto& value) {
|
||||
const JsonObject& process_object = value.as_object();
|
||||
Core::ProcessStatistics process;
|
||||
|
|
|
@ -86,7 +86,7 @@ void TextDocument::set_text(const StringView& text)
|
|||
size_t TextDocumentLine::first_non_whitespace_column() const
|
||||
{
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
if (!isspace(m_text[(int)i]))
|
||||
if (!isspace(m_text[i]))
|
||||
return i;
|
||||
}
|
||||
return length();
|
||||
|
|
|
@ -75,9 +75,9 @@ public:
|
|||
static NonnullRefPtr<TextDocument> create(Client* client = nullptr);
|
||||
~TextDocument();
|
||||
|
||||
size_t line_count() const { return (size_t)m_lines.size(); }
|
||||
const TextDocumentLine& line(size_t line_index) const { return m_lines[(int)line_index]; }
|
||||
TextDocumentLine& line(size_t line_index) { return m_lines[(int)line_index]; }
|
||||
size_t line_count() const { return m_lines.size(); }
|
||||
const TextDocumentLine& line(size_t line_index) const { return m_lines[line_index]; }
|
||||
TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; }
|
||||
|
||||
void set_spans(const Vector<TextDocumentSpan>& spans) { m_spans = spans; }
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
bool has_spans() const { return !m_spans.is_empty(); }
|
||||
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
|
||||
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[(int)index] = move(span); }
|
||||
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); }
|
||||
|
||||
void append_line(NonnullOwnPtr<TextDocumentLine>);
|
||||
void remove_line(size_t line_index);
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
|
||||
StringView view() const { return { characters(), (size_t)length() }; }
|
||||
const char* characters() const { return m_text.data(); }
|
||||
size_t length() const { return (size_t)m_text.size() - 1; }
|
||||
size_t length() const { return m_text.size() - 1; }
|
||||
void set_text(TextDocument&, const StringView&);
|
||||
void append(TextDocument&, char);
|
||||
void prepend(TextDocument&, char);
|
||||
|
|
|
@ -559,7 +559,8 @@ void TextEditor::move_selected_lines_down()
|
|||
get_selection_line_boundaries(first_line, last_line);
|
||||
|
||||
auto& lines = document().lines();
|
||||
if (last_line >= (size_t)(lines.size() - 1))
|
||||
ASSERT(lines.size() != 0);
|
||||
if (last_line >= lines.size() - 1)
|
||||
return;
|
||||
|
||||
lines.insert((int)first_line, lines.take((int)last_line + 1));
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
|
||||
auto buffer = message.encode();
|
||||
|
||||
int nwritten = write(m_socket->fd(), buffer.data(), (size_t)buffer.size());
|
||||
int nwritten = write(m_socket->fd(), buffer.data(), buffer.size());
|
||||
if (nwritten < 0) {
|
||||
switch (errno) {
|
||||
case EPIPE:
|
||||
|
@ -149,7 +149,7 @@ public:
|
|||
}
|
||||
|
||||
size_t decoded_bytes = 0;
|
||||
for (size_t index = 0; index < (size_t)bytes.size(); index += decoded_bytes) {
|
||||
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
||||
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
||||
auto message = Endpoint::decode_message(remaining_bytes, decoded_bytes);
|
||||
if (!message) {
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
bool post_message(const Message& message)
|
||||
{
|
||||
auto buffer = message.encode();
|
||||
int nwritten = write(m_connection->fd(), buffer.data(), (size_t)buffer.size());
|
||||
int nwritten = write(m_connection->fd(), buffer.data(), buffer.size());
|
||||
if (nwritten < 0) {
|
||||
perror("write");
|
||||
ASSERT_NOT_REACHED();
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
}
|
||||
|
||||
size_t decoded_bytes = 0;
|
||||
for (size_t index = 0; index < (size_t)bytes.size(); index += decoded_bytes) {
|
||||
for (size_t index = 0; index < bytes.size(); index += decoded_bytes) {
|
||||
auto remaining_bytes = ByteBuffer::wrap(bytes.data() + index, bytes.size() - index);
|
||||
if (auto message = LocalEndpoint::decode_message(remaining_bytes, decoded_bytes)) {
|
||||
m_unprocessed_messages.append(move(message));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue