7e833f301e
Our biggest object in libsystemd was a table full of zeros, for the arphdr names. Let's use a switch (which gcc nicely optimizes for us), instead a table with a gap between 826 and 65534: $ ls -l build{,2}/src/basic/a6ba3eb@@basic@sta/arphrd-list.c.o -rw-rw-r--. 1 zbyszek zbyszek 540232 Sep 22 00:29 build/src/basic/a6ba3eb\@\@basic\@sta/arphrd-list.c.o -rw-rw-r--. 1 zbyszek zbyszek 20512 Sep 25 11:56 build2/src/basic/a6ba3eb\@\@basic\@sta/arphrd-list.c.o $ ls -l build{,2}/src/shared/libsystemd-shared-243.so -rwxrwxr-x. 1 zbyszek zbyszek 6774368 Sep 22 00:29 build/src/shared/libsystemd-shared-243.so -rwxrwxr-x. 1 zbyszek zbyszek 6254808 Sep 25 12:16 build2/src/shared/libsystemd-shared-243.so No functional change.
26 lines
542 B
C
26 lines
542 B
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#include <errno.h>
|
|
#include <linux/if_arp.h>
|
|
#include <string.h>
|
|
|
|
#include "arphrd-list.h"
|
|
#include "macro.h"
|
|
|
|
static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
|
|
|
|
#include "arphrd-from-name.h"
|
|
#include "arphrd-to-name.h"
|
|
|
|
int arphrd_from_name(const char *name) {
|
|
const struct arphrd_name *sc;
|
|
|
|
assert(name);
|
|
|
|
sc = lookup_arphrd(name, strlen(name));
|
|
if (!sc)
|
|
return -EINVAL;
|
|
|
|
return sc->id;
|
|
}
|