# HG changeset patch # User Paul Eggert # Date 1540481141 25200 # Node ID 34b025ca0b53f8583f7d27cbbd4a4bcd3e5056d3 # Parent e42f23351bef83508bf5445226938c2cdc8d0804 backupfile: tweak for better code * lib/backupfile.c: Sort include directives, and remove unnecessary include. (FALLTHROUGH): New macro, copied from other modules. (backupfile_internal): Use it to avoid code duplication. This lets GCC 8.2.1 generate better code by inlining the call to check_extension. diff -r e42f23351bef -r 34b025ca0b53 ChangeLog --- a/ChangeLog Wed Oct 24 07:26:20 2018 -0700 +++ b/ChangeLog Thu Oct 25 08:25:41 2018 -0700 @@ -1,3 +1,13 @@ +2018-10-25 Paul Eggert + + backupfile: tweak for better code + * lib/backupfile.c: Sort include directives, and remove + unnecessary include. + (FALLTHROUGH): New macro, copied from other modules. + (backupfile_internal): Use it to avoid code duplication. + This lets GCC 8.2.1 generate better code by inlining the + call to check_extension. + 2018-10-23 Paul Eggert backupfile: new dir_fd args diff -r e42f23351bef -r 34b025ca0b53 lib/backupfile.c --- a/lib/backupfile.c Wed Oct 24 07:26:20 2018 -0700 +++ b/lib/backupfile.c Thu Oct 25 08:25:41 2018 -0700 @@ -23,21 +23,26 @@ #include "backup-internal.h" #include "dirname.h" +#include "opendirat.h" #include "renameatu.h" #include "xalloc-oversized.h" +#include #include -#include #include #include #include #include - -#include - #include -#include "opendirat.h" +#ifndef FALLTHROUGH +# if __GNUC__ < 7 +# define FALLTHROUGH ((void) 0) +# else +# define FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +#endif + #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif @@ -351,9 +356,7 @@ memcpy (s + filelen, simple_backup_suffix, simple_backup_suffix_size); } - check_extension (s, filelen, '~', sdir, &base_max); - break; - + FALLTHROUGH; case BACKUP_IS_LONGER: check_extension (s, filelen, '~', sdir, &base_max); break;