From 674b735b95b1d9ec2a55aab18685caac0f133fd9 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 31 Aug 2016 13:15:51 +0300 Subject: [PATCH] git: annotations - remove duplicated `getCurrentRevision` request --- .../src/git4idea/annotate/GitAnnotationProvider.java | 5 +++-- .../git4idea/src/git4idea/annotate/GitFileAnnotation.java | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java b/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java index 2eb5b138dd8b..e3ea1dc6003c 100644 --- a/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java +++ b/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java @@ -129,12 +129,13 @@ public class GitAnnotationProvider implements AnnotationProviderEx { assert vcs != null; VcsRevisionNumber actualRevision = revision != null ? revision : vcs.getDiffProvider().getCurrentRevision(file); + if (actualRevision != null) { Object annotatedData = myCache.get(repositoryFilePath, GitVcs.getKey(), actualRevision); - if (annotatedData instanceof CachedData) return restoreFromCache(file, revision, (CachedData)annotatedData); + if (annotatedData instanceof CachedData) return restoreFromCache(file, actualRevision, (CachedData)annotatedData); } - GitFileAnnotation fileAnnotation = doAnnotate(repositoryFilePath, revision, file); + GitFileAnnotation fileAnnotation = doAnnotate(repositoryFilePath, actualRevision, file); if (actualRevision != null) { myCache.put(repositoryFilePath, GitVcs.getKey(), actualRevision, cacheData(fileAnnotation)); diff --git a/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java b/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java index 8ca02c145245..93bb1f47168f 100644 --- a/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java +++ b/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java @@ -73,16 +73,15 @@ public class GitFileAnnotation extends FileAnnotation { } }; - public GitFileAnnotation(@NotNull final Project project, + public GitFileAnnotation(@NotNull Project project, @NotNull VirtualFile file, - @Nullable final VcsRevisionNumber revision, + @Nullable VcsRevisionNumber revision, @NotNull List lines) { super(project); myProject = project; myFile = file; myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(myProject)); - myBaseRevision = revision == null ? (myVcs.getDiffProvider().getCurrentRevision(file)) : revision; - + myBaseRevision = revision; myLines = lines; }