Browse Source

[performance] Remove synthetic access$ methods in dfs, diff and merge

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: I94fb481b68c84841c1db1a5ebe678b13e13c962b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
stable-4.2
Andrey Loskutov 9 years ago
parent
commit
3afdaf0b3d
  1. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java
  3. 18
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
  4. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java
  5. 4
      org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java

@ -148,7 +148,7 @@ public abstract class ContentSource {
private String current; private String current;
private WorkingTreeIterator ptr; WorkingTreeIterator ptr;
WorkingTreeSource(WorkingTreeIterator iterator) { WorkingTreeSource(WorkingTreeIterator iterator) {
this.tw = new TreeWalk((ObjectReader) null); this.tw = new TreeWalk((ObjectReader) null);

4
org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java

@ -94,7 +94,7 @@ import java.util.List;
*/ */
public class HistogramDiff extends LowLevelDiffAlgorithm { public class HistogramDiff extends LowLevelDiffAlgorithm {
/** Algorithm to use when there are too many element occurrences. */ /** Algorithm to use when there are too many element occurrences. */
private DiffAlgorithm fallback = MyersDiff.INSTANCE; DiffAlgorithm fallback = MyersDiff.INSTANCE;
/** /**
* Maximum number of positions to consider for a given element hash. * Maximum number of positions to consider for a given element hash.
@ -103,7 +103,7 @@ public class HistogramDiff extends LowLevelDiffAlgorithm {
* size is capped to ensure search is linear time at O(len_A + len_B) rather * size is capped to ensure search is linear time at O(len_A + len_B) rather
* than quadratic at O(len_A * len_B). * than quadratic at O(len_A * len_B).
*/ */
private int maxChainLength = 64; int maxChainLength = 64;
/** /**
* Set the algorithm used when there are too many element occurrences. * Set the algorithm used when there are too many element occurrences.

18
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java

@ -95,16 +95,16 @@ public class DfsInserter extends ObjectInserter {
/** Always produce version 2 indexes, to get CRC data. */ /** Always produce version 2 indexes, to get CRC data. */
private static final int INDEX_VERSION = 2; private static final int INDEX_VERSION = 2;
private final DfsObjDatabase db; final DfsObjDatabase db;
private int compression = Deflater.BEST_COMPRESSION; int compression = Deflater.BEST_COMPRESSION;
private List<PackedObjectInfo> objectList; List<PackedObjectInfo> objectList;
private ObjectIdOwnerMap<PackedObjectInfo> objectMap; ObjectIdOwnerMap<PackedObjectInfo> objectMap;
private DfsBlockCache cache; DfsBlockCache cache;
private DfsPackKey packKey; DfsPackKey packKey;
private DfsPackDescription packDsc; DfsPackDescription packDsc;
private PackStream packOut; PackStream packOut;
private boolean rollback; private boolean rollback;
/** /**
@ -322,7 +322,7 @@ public class DfsInserter extends ObjectInserter {
private class PackStream extends OutputStream { private class PackStream extends OutputStream {
private final DfsOutputStream out; private final DfsOutputStream out;
private final MessageDigest md; private final MessageDigest md;
private final byte[] hdrBuf; final byte[] hdrBuf;
private final Deflater deflater; private final Deflater deflater;
private final int blockSize; private final int blockSize;

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java

@ -43,7 +43,7 @@ public class InMemoryRepository extends DfsRepository {
} }
} }
private static final AtomicInteger packId = new AtomicInteger(); static final AtomicInteger packId = new AtomicInteger();
private final DfsObjDatabase objdb; private final DfsObjDatabase objdb;
@ -60,7 +60,7 @@ public class InMemoryRepository extends DfsRepository {
this(new Builder().setRepositoryDescription(repoDesc)); this(new Builder().setRepositoryDescription(repoDesc));
} }
private InMemoryRepository(Builder builder) { InMemoryRepository(Builder builder) {
super(builder); super(builder);
objdb = new MemObjDatabase(this); objdb = new MemObjDatabase(this);
refdb = new MemRefDatabase(); refdb = new MemRefDatabase();
@ -139,7 +139,7 @@ public class InMemoryRepository extends DfsRepository {
} }
private static class MemPack extends DfsPackDescription { private static class MemPack extends DfsPackDescription {
private final Map<PackExt, byte[]> final Map<PackExt, byte[]>
fileMap = new HashMap<PackExt, byte[]>(); fileMap = new HashMap<PackExt, byte[]>();
MemPack(String name, DfsRepositoryDescription repoDesc) { MemPack(String name, DfsRepositoryDescription repoDesc) {

4
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java

@ -70,7 +70,7 @@ import org.eclipse.jgit.util.IntList;
public class MergeResult<S extends Sequence> implements Iterable<MergeChunk> { public class MergeResult<S extends Sequence> implements Iterable<MergeChunk> {
private final List<S> sequences; private final List<S> sequences;
private final IntList chunks = new IntList(); final IntList chunks = new IntList();
private boolean containsConflicts = false; private boolean containsConflicts = false;
@ -127,7 +127,7 @@ public class MergeResult<S extends Sequence> implements Iterable<MergeChunk> {
return sequences; return sequences;
} }
private static final ConflictState[] states = ConflictState.values(); static final ConflictState[] states = ConflictState.values();
/** /**
* @return an iterator over the MergeChunks. The iterator does not support * @return an iterator over the MergeChunks. The iterator does not support

Loading…
Cancel
Save