From 072466c54fb96826ac81ac00bbff4175177d1490 Mon Sep 17 00:00:00 2001 From: blankie Date: Sun, 29 Jan 2023 18:59:33 +0700 Subject: [PATCH] Add a small optimization --- windows/logs.cpp | 4 ++-- windows/main.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/windows/logs.cpp b/windows/logs.cpp index a39e2ba..964e243 100644 --- a/windows/logs.cpp +++ b/windows/logs.cpp @@ -28,8 +28,8 @@ static inline void render_table(ImFont* monospace_font, bool* autoscrolling) { strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&log_entry->time)); ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); ImGui::TextUnformatted(time_as_str); - ImGui::TableSetColumnIndex(1); ImGui::TextUnformatted(log_entry->message); + if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str); + if (ImGui::TableSetColumnIndex(1)) ImGui::TextUnformatted(log_entry->message); } } clipper.End(); diff --git a/windows/main.cpp b/windows/main.cpp index 30e66dd..dac80ff 100644 --- a/windows/main.cpp +++ b/windows/main.cpp @@ -32,17 +32,16 @@ static inline void render_table(ImFont* monospace_font, std::vector strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time)); ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); ImGui::TextUnformatted(time_as_str); - if (logcat_entry->user) { - ImGui::TableSetColumnIndex(1); + if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str); + if (logcat_entry->user && ImGui::TableSetColumnIndex(1)) { ImGui::TextUnformatted(*logcat_entry->user); } - ImGui::TableSetColumnIndex(2); ImGui::Text("%zu", logcat_entry->pid); - ImGui::TableSetColumnIndex(3); ImGui::Text("%zu", logcat_entry->tid); - ImGui::TableSetColumnIndex(4); ImGui::TextUnformatted(buffer_to(logcat_entry->buffer)); - ImGui::TableSetColumnIndex(5); ImGui::TextUnformatted(priority_to(logcat_entry->priority)); - ImGui::TableSetColumnIndex(6); ImGui::TextUnformatted(logcat_entry->tag); - ImGui::TableSetColumnIndex(7); ImGui::TextUnformatted(logcat_entry->message); + if (ImGui::TableSetColumnIndex(2)) ImGui::Text("%zu", logcat_entry->pid); + if (ImGui::TableSetColumnIndex(3)) ImGui::Text("%zu", logcat_entry->tid); + if (ImGui::TableSetColumnIndex(4)) ImGui::TextUnformatted(buffer_to(logcat_entry->buffer)); + if (ImGui::TableSetColumnIndex(5)) ImGui::TextUnformatted(priority_to(logcat_entry->priority)); + if (ImGui::TableSetColumnIndex(6)) ImGui::TextUnformatted(logcat_entry->tag); + if (ImGui::TableSetColumnIndex(7)) ImGui::TextUnformatted(logcat_entry->message); } } clipper.End();