Micro-optimize DeltaWindow maxMemory test to be != 0
Instead of using a compare-with-0 use a does not equal 0. javac bytecode has a special instruction for this, as it is very common in software. We can assume the JIT knows how to efficiently translate the opcode to machine code, and processors can do != 0 very quickly. Change-Id: Idb84c1d744d2874517fd4bfa1db390e2dbf64eac
This commit is contained in:
parent
4db695c1c6
commit
6903fa4a34
|
@ -62,11 +62,8 @@ final class DeltaWindow {
|
|||
private static final int NEXT_SRC = 1;
|
||||
|
||||
private final PackConfig config;
|
||||
|
||||
private final DeltaCache deltaCache;
|
||||
|
||||
private final ObjectReader reader;
|
||||
|
||||
private final ProgressMonitor monitor;
|
||||
|
||||
private final DeltaWindowEntry[] window;
|
||||
|
@ -136,7 +133,7 @@ final class DeltaWindow {
|
|||
for (int i = 0; i < window.length; i++)
|
||||
window[i] = new DeltaWindowEntry();
|
||||
|
||||
maxMemory = config.getDeltaSearchMemoryLimit();
|
||||
maxMemory = Math.max(0, config.getDeltaSearchMemoryLimit());
|
||||
maxDepth = config.getMaxDeltaDepth();
|
||||
}
|
||||
|
||||
|
@ -172,7 +169,7 @@ void search() throws IOException {
|
|||
next = toSearch[cur++];
|
||||
}
|
||||
res = window[resSlot];
|
||||
if (0 < maxMemory) {
|
||||
if (maxMemory != 0) {
|
||||
clear(res);
|
||||
int tail = next(resSlot);
|
||||
final long need = estimateSize(next);
|
||||
|
@ -480,7 +477,7 @@ private DeltaIndex index(DeltaWindowEntry ent)
|
|||
e.setObjectId(ent.object);
|
||||
throw e;
|
||||
}
|
||||
if (0 < maxMemory)
|
||||
if (maxMemory != 0)
|
||||
loaded += idx.getIndexSize() - idx.getSourceSize();
|
||||
ent.index = idx;
|
||||
}
|
||||
|
@ -494,7 +491,7 @@ private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException,
|
|||
checkLoadable(ent, ent.size());
|
||||
|
||||
buf = PackWriter.buffer(config, reader, ent.object);
|
||||
if (0 < maxMemory)
|
||||
if (maxMemory != 0)
|
||||
loaded += buf.length;
|
||||
ent.buffer = buf;
|
||||
}
|
||||
|
@ -502,7 +499,7 @@ private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException,
|
|||
}
|
||||
|
||||
private void checkLoadable(DeltaWindowEntry ent, long need) {
|
||||
if (maxMemory <= 0)
|
||||
if (maxMemory == 0)
|
||||
return;
|
||||
|
||||
int tail = next(resSlot);
|
||||
|
|
Loading…
Reference in New Issue