Browse Source

Declare critical exposed methods of ObjectToPack final

There is no reasonable way for a subclass to correctly override and
implement these methods. They depend on internal state that cannot
otherwise be managed.

Most of these methods are also in critical paths of PackWriter.
Declare them final so subclasses do not try to replace them,
and so the JIT knows the smaller ones can be safely inlined.

Change-Id: I9026938e5833ac0b94246d21c69a143a9224626c
stable-3.0
Shawn Pearce 12 years ago
parent
commit
d45277a691
  1. 22
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java

22
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java

@ -124,7 +124,7 @@ public class ObjectToPack extends PackedObjectInfo {
* representation; null otherwise - if going to be packed as a
* whole object.
*/
public ObjectId getDeltaBaseId() {
public final ObjectId getDeltaBaseId() {
return deltaBase;
}
@ -134,7 +134,7 @@ public class ObjectToPack extends PackedObjectInfo {
* pack; null otherwise - if going to be packed as a whole
* object or delta base is specified only as id.
*/
public ObjectToPack getDeltaBase() {
public final ObjectToPack getDeltaBase() {
if (deltaBase instanceof ObjectToPack)
return (ObjectToPack) deltaBase;
return null;
@ -179,7 +179,7 @@ public class ObjectToPack extends PackedObjectInfo {
* @return true if object is going to be written as delta; false
* otherwise.
*/
public boolean isDeltaRepresentation() {
public final boolean isDeltaRepresentation() {
return deltaBase != null;
}
@ -189,12 +189,12 @@ public class ObjectToPack extends PackedObjectInfo {
*
* @return true if object is already written; false otherwise.
*/
public boolean isWritten() {
public final boolean isWritten() {
return getOffset() != 0;
}
/** @return the type of this object. */
public int getType() {
public final int getType() {
return (flags >> TYPE_SHIFT) & 0x7;
}
@ -218,7 +218,7 @@ public class ObjectToPack extends PackedObjectInfo {
* @return true if an existing representation was selected to be reused
* as-is into the pack stream.
*/
public boolean isReuseAsIs() {
public final boolean isReuseAsIs() {
return (flags & REUSE_AS_IS) != 0;
}
@ -266,7 +266,7 @@ public class ObjectToPack extends PackedObjectInfo {
}
/** @return the extended flags on this object, in the range [0x0, 0xf]. */
protected int getExtendedFlags() {
protected final int getExtendedFlags() {
return (flags >>> EXT_SHIFT) & EXT_MASK;
}
@ -280,7 +280,7 @@ public class ObjectToPack extends PackedObjectInfo {
* the flag mask to test, must be between 0x0 and 0xf.
* @return true if any of the bits matching the mask are non-zero.
*/
protected boolean isExtendedFlag(int flag) {
protected final boolean isExtendedFlag(int flag) {
return (flags & (flag << EXT_SHIFT)) != 0;
}
@ -293,7 +293,7 @@ public class ObjectToPack extends PackedObjectInfo {
* @param flag
* the bits to set, must be between 0x0 and 0xf.
*/
protected void setExtendedFlag(int flag) {
protected final void setExtendedFlag(int flag) {
flags |= (flag & EXT_MASK) << EXT_SHIFT;
}
@ -306,7 +306,7 @@ public class ObjectToPack extends PackedObjectInfo {
* @param flag
* the bits to clear, must be between 0x0 and 0xf.
*/
protected void clearExtendedFlag(int flag) {
protected final void clearExtendedFlag(int flag) {
flags &= ~((flag & EXT_MASK) << EXT_SHIFT);
}
@ -320,7 +320,7 @@ public class ObjectToPack extends PackedObjectInfo {
* additional flag bits to store in the flags field. Due to space
* constraints only values [0x0, 0xf] are permitted.
*/
protected void setExtendedFlags(int extFlags) {
protected final void setExtendedFlags(int extFlags) {
flags = ((extFlags & EXT_MASK) << EXT_SHIFT) | (flags & NON_EXT_MASK);
}

Loading…
Cancel
Save