From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 4/5] diff_filespec: reorder is_binary field
Date: Thu, 16 Jan 2014 20:22:56 -0500 [thread overview]
Message-ID: <20140117012255.GD7249@sigill.intra.peff.net> (raw)
In-Reply-To: <20140117011844.GA6870@sigill.intra.peff.net>
The middle of the diff_filespec struct contains a mixture of
ints, shorts, and bit-fields, followed by a pointer. On an
x86-64 system with an LP64 or LLP64 data model (i.e., most
of them), the integers and flags end up being padded out by
41 bits to put the pointer at an 8-byte boundary.
After the pointer, we have the "int is_binary" field, which
is only 32 bits. We end up wasting another 32 bits to pad
the struct size up to a multiple of 64 bits.
We can move the is_binary field before the pointer, which
lets the compiler store it where we used to have padding.
This shrinks the top padding to only 9 bits (from the
bit-fields), and eliminates the bottom padding entirely,
dropping the struct size from 88 to 80 bytes.
On a 32-bit system, there is no benefit, but nor should
there be any harm (we only need 4-byte alignment there, so
we were already using only 9 bits of padding).
Signed-off-by: Jeff King <peff@peff.net>
---
diffcore.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diffcore.h b/diffcore.h
index 22993e1..d911bf0 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -45,9 +45,9 @@ struct diff_filespec {
#define DIRTY_SUBMODULE_MODIFIED 2
unsigned is_stdin : 1;
unsigned has_more_entries : 1; /* only appear in combined diff */
- struct userdiff_driver *driver;
/* data should be considered "binary"; -1 means "don't know yet" */
int is_binary;
+ struct userdiff_driver *driver;
};
extern struct diff_filespec *alloc_filespec(const char *);
--
1.8.5.2.500.g8060133
next prev parent reply other threads:[~2014-01-17 1:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 1:18 [PATCH 0/5] diff_filespec cleanups and optimizations Jeff King
2014-01-17 1:19 ` [PATCH 1/5] diff_filespec: reorder dirty_submodule macro definitions Jeff King
2014-01-17 18:46 ` Junio C Hamano
2014-01-17 19:47 ` Jeff King
2014-01-17 23:50 ` Junio C Hamano
2014-01-17 1:20 ` [PATCH 2/5] diff_filespec: drop funcname_pattern_ident field Jeff King
2014-01-17 1:21 ` [PATCH 3/5] diff_filespec: drop xfrm_flags field Jeff King
2014-01-17 1:22 ` Jeff King [this message]
2014-01-17 1:25 ` [PATCH 5/5] diff_filespec: use only 2 bits for is_binary flag Jeff King
2014-01-17 18:49 ` [PATCH 0/5] diff_filespec cleanups and optimizations Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140117012255.GD7249@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).