Browse Source

Declare internal flag accessors of ObjectToPack final

None of these methods should ever be overridden at runtime by an
extension class. Given how small they are the JIT should perform
inlining where reasonable. Hint this is possible by marking all
methods final so its clear no replacement can be loaded later on.

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

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

@ -150,22 +150,22 @@ public class ObjectToPack extends PackedObjectInfo {
* whole object. * whole object.
* *
*/ */
void setDeltaBase(ObjectId deltaBase) { final void setDeltaBase(ObjectId deltaBase) {
this.deltaBase = deltaBase; this.deltaBase = deltaBase;
} }
void setCachedDelta(DeltaCache.Ref data){ final void setCachedDelta(DeltaCache.Ref data) {
cachedDelta = data; cachedDelta = data;
} }
DeltaCache.Ref popCachedDelta() { final DeltaCache.Ref popCachedDelta() {
DeltaCache.Ref r = cachedDelta; DeltaCache.Ref r = cachedDelta;
if (r != null) if (r != null)
cachedDelta = null; cachedDelta = null;
return r; return r;
} }
void clearDeltaBase() { final void clearDeltaBase() {
this.deltaBase = null; this.deltaBase = null;
if (cachedDelta != null) { if (cachedDelta != null) {
@ -198,19 +198,19 @@ public class ObjectToPack extends PackedObjectInfo {
return (flags >> TYPE_SHIFT) & 0x7; return (flags >> TYPE_SHIFT) & 0x7;
} }
int getDeltaDepth() { final int getDeltaDepth() {
return flags >>> DELTA_SHIFT; return flags >>> DELTA_SHIFT;
} }
void setDeltaDepth(int d) { final void setDeltaDepth(int d) {
flags = (d << DELTA_SHIFT) | (flags & NON_DELTA_MASK); flags = (d << DELTA_SHIFT) | (flags & NON_DELTA_MASK);
} }
boolean wantWrite() { final boolean wantWrite() {
return (flags & WANT_WRITE) != 0; return (flags & WANT_WRITE) != 0;
} }
void markWantWrite() { final void markWantWrite() {
flags |= WANT_WRITE; flags |= WANT_WRITE;
} }
@ -222,7 +222,7 @@ public class ObjectToPack extends PackedObjectInfo {
return (flags & REUSE_AS_IS) != 0; return (flags & REUSE_AS_IS) != 0;
} }
void setReuseAsIs() { final void setReuseAsIs() {
flags |= REUSE_AS_IS; flags |= REUSE_AS_IS;
} }
@ -237,28 +237,28 @@ public class ObjectToPack extends PackedObjectInfo {
flags &= ~REUSE_AS_IS; flags &= ~REUSE_AS_IS;
} }
boolean isDoNotDelta() { final boolean isDoNotDelta() {
return (flags & DO_NOT_DELTA) != 0; return (flags & DO_NOT_DELTA) != 0;
} }
void setDoNotDelta() { final void setDoNotDelta() {
flags |= DO_NOT_DELTA; flags |= DO_NOT_DELTA;
} }
boolean isEdge() { final boolean isEdge() {
return (flags & EDGE) != 0; return (flags & EDGE) != 0;
} }
void setEdge() { final void setEdge() {
flags |= EDGE; flags |= EDGE;
} }
boolean doNotAttemptDelta() { final boolean doNotAttemptDelta() {
// Do not attempt if delta attempted and object reuse. // Do not attempt if delta attempted and object reuse.
return (flags & ATTEMPT_DELTA_MASK) == ATTEMPT_DELTA_MASK; return (flags & ATTEMPT_DELTA_MASK) == ATTEMPT_DELTA_MASK;
} }
void setDeltaAttempted(boolean deltaAttempted) { final void setDeltaAttempted(boolean deltaAttempted) {
if (deltaAttempted) if (deltaAttempted)
flags |= DELTA_ATTEMPTED; flags |= DELTA_ATTEMPTED;
else else
@ -324,7 +324,7 @@ public class ObjectToPack extends PackedObjectInfo {
flags = ((extFlags & EXT_MASK) << EXT_SHIFT) | (flags & NON_EXT_MASK); flags = ((extFlags & EXT_MASK) << EXT_SHIFT) | (flags & NON_EXT_MASK);
} }
int getFormat() { final int getFormat() {
if (isReuseAsIs()) { if (isReuseAsIs()) {
if (isDeltaRepresentation()) if (isDeltaRepresentation())
return StoredObjectRepresentation.PACK_DELTA; return StoredObjectRepresentation.PACK_DELTA;
@ -334,27 +334,27 @@ public class ObjectToPack extends PackedObjectInfo {
} }
// Overload weight into CRC since we don't need them at the same time. // Overload weight into CRC since we don't need them at the same time.
int getWeight() { final int getWeight() {
return getCRC(); return getCRC();
} }
void setWeight(int weight) { final void setWeight(int weight) {
setCRC(weight); setCRC(weight);
} }
int getPathHash() { final int getPathHash() {
return pathHash; return pathHash;
} }
void setPathHash(int hc) { final void setPathHash(int hc) {
pathHash = hc; pathHash = hc;
} }
int getCachedSize() { final int getCachedSize() {
return pathHash; return pathHash;
} }
void setCachedSize(int sz) { final void setCachedSize(int sz) {
pathHash = sz; pathHash = sz;
} }

Loading…
Cancel
Save