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 static final int NEXT_SRC = 1;
|
||||||
|
|
||||||
private final PackConfig config;
|
private final PackConfig config;
|
||||||
|
|
||||||
private final DeltaCache deltaCache;
|
private final DeltaCache deltaCache;
|
||||||
|
|
||||||
private final ObjectReader reader;
|
private final ObjectReader reader;
|
||||||
|
|
||||||
private final ProgressMonitor monitor;
|
private final ProgressMonitor monitor;
|
||||||
|
|
||||||
private final DeltaWindowEntry[] window;
|
private final DeltaWindowEntry[] window;
|
||||||
|
@ -136,7 +133,7 @@ final class DeltaWindow {
|
||||||
for (int i = 0; i < window.length; i++)
|
for (int i = 0; i < window.length; i++)
|
||||||
window[i] = new DeltaWindowEntry();
|
window[i] = new DeltaWindowEntry();
|
||||||
|
|
||||||
maxMemory = config.getDeltaSearchMemoryLimit();
|
maxMemory = Math.max(0, config.getDeltaSearchMemoryLimit());
|
||||||
maxDepth = config.getMaxDeltaDepth();
|
maxDepth = config.getMaxDeltaDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +169,7 @@ void search() throws IOException {
|
||||||
next = toSearch[cur++];
|
next = toSearch[cur++];
|
||||||
}
|
}
|
||||||
res = window[resSlot];
|
res = window[resSlot];
|
||||||
if (0 < maxMemory) {
|
if (maxMemory != 0) {
|
||||||
clear(res);
|
clear(res);
|
||||||
int tail = next(resSlot);
|
int tail = next(resSlot);
|
||||||
final long need = estimateSize(next);
|
final long need = estimateSize(next);
|
||||||
|
@ -480,7 +477,7 @@ private DeltaIndex index(DeltaWindowEntry ent)
|
||||||
e.setObjectId(ent.object);
|
e.setObjectId(ent.object);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
if (0 < maxMemory)
|
if (maxMemory != 0)
|
||||||
loaded += idx.getIndexSize() - idx.getSourceSize();
|
loaded += idx.getIndexSize() - idx.getSourceSize();
|
||||||
ent.index = idx;
|
ent.index = idx;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +491,7 @@ private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException,
|
||||||
checkLoadable(ent, ent.size());
|
checkLoadable(ent, ent.size());
|
||||||
|
|
||||||
buf = PackWriter.buffer(config, reader, ent.object);
|
buf = PackWriter.buffer(config, reader, ent.object);
|
||||||
if (0 < maxMemory)
|
if (maxMemory != 0)
|
||||||
loaded += buf.length;
|
loaded += buf.length;
|
||||||
ent.buffer = buf;
|
ent.buffer = buf;
|
||||||
}
|
}
|
||||||
|
@ -502,7 +499,7 @@ private byte[] buffer(DeltaWindowEntry ent) throws MissingObjectException,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLoadable(DeltaWindowEntry ent, long need) {
|
private void checkLoadable(DeltaWindowEntry ent, long need) {
|
||||||
if (maxMemory <= 0)
|
if (maxMemory == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int tail = next(resSlot);
|
int tail = next(resSlot);
|
||||||
|
|
Loading…
Reference in New Issue