]> git.ipfire.org Git - thirdparty/systemd.git/commit
journal: loop less in MATCH_AND_TERM conditionals
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Jun 2013 04:56:03 +0000 (00:56 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jun 2013 14:10:06 +0000 (10:10 -0400)
commit2bc8ca0ca2fefcfb63a37723d7a9bbb9ae76ceb1
tree2a0647e78377f9b27d8b4b3e37af040c012ccce2
parent3f3a438f58d7b1d2ba2b44d6d356fb1eaa65b66a
journal: loop less in MATCH_AND_TERM conditionals

AND term usually don't have many subterms (4 seems to be the maximum
sensible number, e.g. _BOOT_ID && _SYSTEMD_UNIT && _PID && MESSAGE_ID).
Nevertheless, the cost of checking each subterm can be relatively
high, especially when the nested terms are compound, and it
makes sense to minimize the number of checks.

Instead of looping to the end and then again over the whole list once
again after at least one term changed the offset, start the loop at
the term which caused the change. This way ½ terms in the AND match
are not checked unnecessarily again.
src/journal/sd-journal.c
src/shared/list.h