summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-01-19 11:35:36 +0100
committerLennart Poettering <lennart@poettering.net>2023-01-20 21:46:01 +0100
commitc5da14cd59e51d704c0fcf1d34798198ba51a5bc (patch)
tree315ab4fde15c85d306d5ea01b8a38f1b5ff6c466 /src/journal
parent8ba814df255e5b65c36048355b22f757a0ccb6cb (diff)
downloadsystemd-c5da14cd59e51d704c0fcf1d34798198ba51a5bc.tar.gz
journalctl: don't convert between strv/Set for each log line
If output fields are specified, let's store this in a Set right-away, instead of converting between strv and Set again and again for each line. This is not only faster, but also simpler and shorter.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journalctl.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index dd28517924..b2883ff177 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -129,7 +129,7 @@ static const char *arg_namespace = NULL;
static uint64_t arg_vacuum_size = 0;
static uint64_t arg_vacuum_n_files = 0;
static usec_t arg_vacuum_time = 0;
-static char **arg_output_fields = NULL;
+static Set *arg_output_fields = NULL;
static const char *arg_pattern = NULL;
static pcre2_code *arg_compiled_pattern = NULL;
static PatternCompileCase arg_case = PATTERN_COMPILE_CASE_AUTO;
@@ -142,7 +142,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_system_units, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_user_units, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
-STATIC_DESTRUCTOR_REGISTER(arg_output_fields, strv_freep);
+STATIC_DESTRUCTOR_REGISTER(arg_output_fields, set_freep);
STATIC_DESTRUCTOR_REGISTER(arg_compiled_pattern, pattern_freep);
static enum {
@@ -1026,13 +1026,10 @@ static int parse_argv(int argc, char *argv[]) {
if (!v)
return log_oom();
- if (!arg_output_fields)
- arg_output_fields = TAKE_PTR(v);
- else {
- r = strv_extend_strv(&arg_output_fields, v, true);
- if (r < 0)
- return log_oom();
- }
+ r = set_put_strdupv(&arg_output_fields, v);
+ if (r < 0)
+ return log_oom();
+
break;
}