]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: store NE hash instead of LE hash in Match object
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Jun 2020 16:06:16 +0000 (18:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Jun 2020 13:00:59 +0000 (15:00 +0200)
We keep converting forth and back though we never need it in LE. Let's
stop doing those conversions hence.

src/journal/journal-internal.h
src/journal/sd-journal.c

index e1fb01a6e38ab823c77b740292566e3264c17272..028f0d9055d470480e075c7087506302bb2f16c0 100644 (file)
@@ -32,7 +32,7 @@ struct Match {
         /* For concrete matches */
         char *data;
         size_t size;
-        le64_t le_hash;
+        uint64_t hash;
 
         /* For terms */
         LIST_HEAD(Match, matches);
index 80cd80f3568969fbc16042274b1202cccce63df3..7e958e9f43140dc9476a68f17bb3f0cd082449e0 100644 (file)
@@ -240,7 +240,7 @@ static void match_free_if_empty(Match *m) {
 
 _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size) {
         Match *l3, *l4, *add_here = NULL, *m;
-        le64_t le_hash;
+        uint64_t hash;
 
         assert_return(j, -EINVAL);
         assert_return(!journal_pid_changed(j), -ECHILD);
@@ -279,7 +279,7 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
         assert(j->level1->type == MATCH_OR_TERM);
         assert(j->level2->type == MATCH_AND_TERM);
 
-        le_hash = htole64(hash64(data, size));
+        hash = hash64(data, size);
 
         LIST_FOREACH(matches, l3, j->level2->matches) {
                 assert(l3->type == MATCH_OR_TERM);
@@ -289,7 +289,7 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
 
                         /* Exactly the same match already? Then ignore
                          * this addition */
-                        if (l4->le_hash == le_hash &&
+                        if (l4->hash == hash &&
                             l4->size == size &&
                             memcmp(l4->data, data, size) == 0)
                                 return 0;
@@ -315,7 +315,7 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
         if (!m)
                 goto fail;
 
-        m->le_hash = le_hash;
+        m->hash = hash;
         m->size = size;
         m->data = memdup(data, size);
         if (!m->data)
@@ -503,7 +503,7 @@ static int next_for_match(
         if (m->type == MATCH_DISCRETE) {
                 uint64_t dp;
 
-                r = journal_file_find_data_object_with_hash(f, m->data, m->size, le64toh(m->le_hash), NULL, &dp);
+                r = journal_file_find_data_object_with_hash(f, m->data, m->size, m->hash, NULL, &dp);
                 if (r <= 0)
                         return r;
 
@@ -592,7 +592,7 @@ static int find_location_for_match(
         if (m->type == MATCH_DISCRETE) {
                 uint64_t dp;
 
-                r = journal_file_find_data_object_with_hash(f, m->data, m->size, le64toh(m->le_hash), NULL, &dp);
+                r = journal_file_find_data_object_with_hash(f, m->data, m->size, m->hash, NULL, &dp);
                 if (r <= 0)
                         return r;