This reduces the ObjectToPack structure by 4 bytes, saving us 4 MB on the linux kernel repository. Its only a single bit value, so keeping it in a full boolean is rather wasteful given how many of these objects we need in to pack a large project. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/lib/PackWriter.java | 23 ++++++++++++------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java index 50d06c2..3ef9154 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java @@ -859,11 +859,16 @@ public void addObject(final RevObject object) private PackedObjectLoader reuseLoader; - /** Low bits contain the objectType; higher bits the deltaDepth */ + /** + * Bit field, from bit 0 to bit 31: + * <ul> + * <li>1 bit: wantWrite</li> + * <li>3 bits: type</li> + * <li>28 bits: deltaDepth</li> + * </ul> + */ private int flags; - private boolean wantWrite; - /** * Construct object for specified object id. <br/> By default object is * marked as not written and non-delta packed (as a whole object). @@ -875,7 +880,7 @@ public void addObject(final RevObject object) */ ObjectToPack(AnyObjectId src, final int type) { super(src); - flags |= type; + flags |= type << 1; } /** @@ -952,11 +957,11 @@ void disposeLoader() { } int getType() { - return flags & 0x7; + return (flags>>1) & 0x7; } int getDeltaDepth() { - return flags >>> 3; + return flags >>> 4; } void updateDeltaDepth() { @@ -967,15 +972,15 @@ else if (deltaBase != null) d = 1; else d = 0; - flags = (d << 3) | getType(); + flags = (d << 4) | flags & 0x15; } boolean wantWrite() { - return wantWrite; + return (flags & 1) == 1; } void markWantWrite() { - this.wantWrite = true; + flags |= 1; } } } -- 1.6.1.rc4.301.g5497a -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html