From 3afdaf0b3de90f4eec2933cd6f33e285d820984b Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 28 Oct 2015 21:17:43 +0100 Subject: [PATCH] [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$" 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 --- .../org/eclipse/jgit/diff/ContentSource.java | 2 +- .../org/eclipse/jgit/diff/HistogramDiff.java | 4 ++-- .../jgit/internal/storage/dfs/DfsInserter.java | 18 +++++++++--------- .../storage/dfs/InMemoryRepository.java | 6 +++--- .../org/eclipse/jgit/merge/MergeResult.java | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java index 3c780e7d8..0dc4b0578 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/ContentSource.java @@ -148,7 +148,7 @@ public abstract class ContentSource { private String current; - private WorkingTreeIterator ptr; + WorkingTreeIterator ptr; WorkingTreeSource(WorkingTreeIterator iterator) { this.tw = new TreeWalk((ObjectReader) null); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java index e57faaf85..2f5c9ea84 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java @@ -94,7 +94,7 @@ import java.util.List; */ public class HistogramDiff extends LowLevelDiffAlgorithm { /** 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. @@ -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 * 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. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java index 488eee979..aea453e81 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java +++ b/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. */ private static final int INDEX_VERSION = 2; - private final DfsObjDatabase db; - private int compression = Deflater.BEST_COMPRESSION; + final DfsObjDatabase db; + int compression = Deflater.BEST_COMPRESSION; - private List objectList; - private ObjectIdOwnerMap objectMap; + List objectList; + ObjectIdOwnerMap objectMap; - private DfsBlockCache cache; - private DfsPackKey packKey; - private DfsPackDescription packDsc; - private PackStream packOut; + DfsBlockCache cache; + DfsPackKey packKey; + DfsPackDescription packDsc; + PackStream packOut; private boolean rollback; /** @@ -322,7 +322,7 @@ public class DfsInserter extends ObjectInserter { private class PackStream extends OutputStream { private final DfsOutputStream out; private final MessageDigest md; - private final byte[] hdrBuf; + final byte[] hdrBuf; private final Deflater deflater; private final int blockSize; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java index 8e7af0d29..832e4fb6a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java +++ b/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; @@ -60,7 +60,7 @@ public class InMemoryRepository extends DfsRepository { this(new Builder().setRepositoryDescription(repoDesc)); } - private InMemoryRepository(Builder builder) { + InMemoryRepository(Builder builder) { super(builder); objdb = new MemObjDatabase(this); refdb = new MemRefDatabase(); @@ -139,7 +139,7 @@ public class InMemoryRepository extends DfsRepository { } private static class MemPack extends DfsPackDescription { - private final Map + final Map fileMap = new HashMap(); MemPack(String name, DfsRepositoryDescription repoDesc) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java index dc3c772ef..106f9c779 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java @@ -70,7 +70,7 @@ import org.eclipse.jgit.util.IntList; public class MergeResult implements Iterable { private final List sequences; - private final IntList chunks = new IntList(); + final IntList chunks = new IntList(); private boolean containsConflicts = false; @@ -127,7 +127,7 @@ public class MergeResult implements Iterable { 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