]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic: more optimizable IN_SET macro 660/head
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 22 Jul 2015 15:50:44 +0000 (17:50 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Wed, 22 Jul 2015 17:31:17 +0000 (19:31 +0200)
commit77247cba3e8f94a3f58d16ec338ae030eb9145af
treecfefdbb4f31662df3c2b2b31d3ca68fe2c5dc566
parent249a2737ba5d0a22f09f077b361d01d514eaf672
basic: more optimizable IN_SET macro

Making the array static allows gcc -O2 to generate smaller code:

"size systemd" before:
   text    data     bss     dec     hex filename
1377286  128608    2632 1508526  1704ae systemd

After:
   text    data     bss     dec     hex filename
1374326  128572    2664 1505562  16f91a systemd

(IN_SET still results in worse generated code than using
 "x == FOO || x == BAR || ...". I don't think we'll be able to match
 that with the C preprocessor.)

This change limits the use of IN_SET to sets with constant elements. All
present callers use constants. The compiler would report an "initializer
element is not constant" error otherwise.
src/basic/macro.h