diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-20 14:02:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-20 14:02:19 +0200 |
commit | 5eedb2283488fafef98c20729bc6917c6de957e5 (patch) | |
tree | 99f5fa12e15a4134f5b53f13ab34dcca1cb5efbf /Applications | |
parent | 7faf8fabf20d703141bc873716e8bea7692d1975 (diff) | |
download | serenity-5eedb2283488fafef98c20729bc6917c6de957e5.zip |
Sprinkle use of AK::Vector in various places.
Some of these are less helpful than others. Avoiding a bunch of mallocs
in the event loop wakeup code is definitely nice.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/FileManager/DirectoryModel.cpp | 1 | ||||
-rw-r--r-- | Applications/IRCClient/IRCClient.cpp | 6 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessModel.cpp | 2 | ||||
-rw-r--r-- | Applications/Terminal/Terminal.cpp | 34 | ||||
-rw-r--r-- | Applications/Terminal/Terminal.h | 34 |
5 files changed, 40 insertions, 37 deletions
diff --git a/Applications/FileManager/DirectoryModel.cpp b/Applications/FileManager/DirectoryModel.cpp index c15eb0f317..42a25a453e 100644 --- a/Applications/FileManager/DirectoryModel.cpp +++ b/Applications/FileManager/DirectoryModel.cpp @@ -26,6 +26,7 @@ int thumbnail_thread(void* model_ptr) Vector<String> to_generate; { LOCKER(thumbnail_cache().lock()); + to_generate.ensure_capacity(thumbnail_cache().resource().size()); for (auto& it : thumbnail_cache().resource()) { if (it.value) continue; diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp index 5c53b1e84a..67f1854ba1 100644 --- a/Applications/IRCClient/IRCClient.cpp +++ b/Applications/IRCClient/IRCClient.cpp @@ -87,9 +87,9 @@ void IRCClient::receive_from_server() void IRCClient::process_line(ByteBuffer&& line) { Message msg; - Vector<char> prefix; - Vector<char> command; - Vector<char> current_parameter; + Vector<char, 32> prefix; + Vector<char, 32> command; + Vector<char, 256> current_parameter; enum { Start, InPrefix, diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp index 9679b36815..9ed93c3e86 100644 --- a/Applications/ProcessManager/ProcessModel.cpp +++ b/Applications/ProcessManager/ProcessModel.cpp @@ -193,7 +193,7 @@ void ProcessModel::update() } m_pids.clear(); - Vector<pid_t> pids_to_remove; + Vector<pid_t, 16> pids_to_remove; for (auto& it : m_processes) { if (!live_pids.contains(it.key)) { pids_to_remove.append(it.key); diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index a8e6267858..53ceef4cdf 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -136,7 +136,7 @@ static inline Color lookup_color(unsigned color) return Color::from_rgb(xterm_colors[color]); } -void Terminal::escape$m(const Vector<unsigned>& params) +void Terminal::escape$m(const ParamVector& params) { if (params.size() == 3 && params[1] == 5) { if (params[0] == 38) { @@ -183,25 +183,25 @@ void Terminal::escape$m(const Vector<unsigned>& params) } } -void Terminal::escape$s(const Vector<unsigned>&) +void Terminal::escape$s(const ParamVector&) { m_saved_cursor_row = m_cursor_row; m_saved_cursor_column = m_cursor_column; } -void Terminal::escape$u(const Vector<unsigned>&) +void Terminal::escape$u(const ParamVector&) { set_cursor(m_saved_cursor_row, m_saved_cursor_column); } -void Terminal::escape$t(const Vector<unsigned>& params) +void Terminal::escape$t(const ParamVector& params) { if (params.size() < 1) return; dbgprintf("FIXME: escape$t: Ps: %u\n", params[0]); } -void Terminal::escape$r(const Vector<unsigned>& params) +void Terminal::escape$r(const ParamVector& params) { unsigned top = 1; unsigned bottom = m_rows; @@ -212,7 +212,7 @@ void Terminal::escape$r(const Vector<unsigned>& params) dbgprintf("FIXME: escape$r: Set scrolling region: %u-%u\n", top, bottom); } -void Terminal::escape$H(const Vector<unsigned>& params) +void Terminal::escape$H(const ParamVector& params) { unsigned row = 1; unsigned col = 1; @@ -223,7 +223,7 @@ void Terminal::escape$H(const Vector<unsigned>& params) set_cursor(row - 1, col - 1); } -void Terminal::escape$A(const Vector<unsigned>& params) +void Terminal::escape$A(const ParamVector& params) { int num = 1; if (params.size() >= 1) @@ -236,7 +236,7 @@ void Terminal::escape$A(const Vector<unsigned>& params) set_cursor(new_row, m_cursor_column); } -void Terminal::escape$B(const Vector<unsigned>& params) +void Terminal::escape$B(const ParamVector& params) { int num = 1; if (params.size() >= 1) @@ -249,7 +249,7 @@ void Terminal::escape$B(const Vector<unsigned>& params) set_cursor(new_row, m_cursor_column); } -void Terminal::escape$C(const Vector<unsigned>& params) +void Terminal::escape$C(const ParamVector& params) { int num = 1; if (params.size() >= 1) @@ -262,7 +262,7 @@ void Terminal::escape$C(const Vector<unsigned>& params) set_cursor(m_cursor_row, new_column); } -void Terminal::escape$D(const Vector<unsigned>& params) +void Terminal::escape$D(const ParamVector& params) { int num = 1; if (params.size() >= 1) @@ -275,7 +275,7 @@ void Terminal::escape$D(const Vector<unsigned>& params) set_cursor(m_cursor_row, new_column); } -void Terminal::escape$G(const Vector<unsigned>& params) +void Terminal::escape$G(const ParamVector& params) { int new_column = 1; if (params.size() >= 1) @@ -285,7 +285,7 @@ void Terminal::escape$G(const Vector<unsigned>& params) set_cursor(m_cursor_row, new_column); } -void Terminal::escape$d(const Vector<unsigned>& params) +void Terminal::escape$d(const ParamVector& params) { int new_row = 1; if (params.size() >= 1) @@ -295,7 +295,7 @@ void Terminal::escape$d(const Vector<unsigned>& params) set_cursor(new_row, m_cursor_column); } -void Terminal::escape$X(const Vector<unsigned>& params) +void Terminal::escape$X(const ParamVector& params) { // Erase characters (without moving cursor) int num = 1; @@ -309,7 +309,7 @@ void Terminal::escape$X(const Vector<unsigned>& params) } } -void Terminal::escape$K(const Vector<unsigned>& params) +void Terminal::escape$K(const ParamVector& params) { int mode = 0; if (params.size() >= 1) @@ -336,7 +336,7 @@ void Terminal::escape$K(const Vector<unsigned>& params) } } -void Terminal::escape$J(const Vector<unsigned>& params) +void Terminal::escape$J(const ParamVector& params) { int mode = 0; if (params.size() >= 1) @@ -370,7 +370,7 @@ void Terminal::escape$J(const Vector<unsigned>& params) } } -void Terminal::escape$M(const Vector<unsigned>& params) +void Terminal::escape$M(const ParamVector& params) { int count = 1; if (params.size() >= 1) @@ -414,7 +414,7 @@ void Terminal::execute_escape_sequence(byte final) { m_final = final; auto paramparts = String((const char*)m_parameters.data(), m_parameters.size()).split(';'); - Vector<unsigned> params; + ParamVector params; for (auto& parampart : paramparts) { bool ok; unsigned value = parse_uint(parampart, ok); diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index 724b128772..faee6ed02a 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -25,6 +25,8 @@ public: void apply_size_increments_to_window(GWindow&); private: + typedef Vector<unsigned, 4> ParamVector; + virtual void event(CEvent&) override; virtual void paint_event(GPaintEvent&) override; virtual void resize_event(GResizeEvent&) override; @@ -42,22 +44,22 @@ private: void unimplemented_escape(); void unimplemented_xterm_escape(); - void escape$A(const Vector<unsigned>&); - void escape$B(const Vector<unsigned>&); - void escape$C(const Vector<unsigned>&); - void escape$D(const Vector<unsigned>&); - void escape$H(const Vector<unsigned>&); - void escape$J(const Vector<unsigned>&); - void escape$K(const Vector<unsigned>&); - void escape$M(const Vector<unsigned>&); - void escape$G(const Vector<unsigned>&); - void escape$X(const Vector<unsigned>&); - void escape$d(const Vector<unsigned>&); - void escape$m(const Vector<unsigned>&); - void escape$s(const Vector<unsigned>&); - void escape$u(const Vector<unsigned>&); - void escape$t(const Vector<unsigned>&); - void escape$r(const Vector<unsigned>&); + void escape$A(const ParamVector&); + void escape$B(const ParamVector&); + void escape$C(const ParamVector&); + void escape$D(const ParamVector&); + void escape$H(const ParamVector&); + void escape$J(const ParamVector&); + void escape$K(const ParamVector&); + void escape$M(const ParamVector&); + void escape$G(const ParamVector&); + void escape$X(const ParamVector&); + void escape$d(const ParamVector&); + void escape$m(const ParamVector&); + void escape$s(const ParamVector&); + void escape$u(const ParamVector&); + void escape$t(const ParamVector&); + void escape$r(const ParamVector&); void clear(); |