From 94938baefc2ea3dfdbaf5b37f9971429ddf24557 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Sat, 28 Jan 2017 20:03:30 +0300 Subject: [PATCH] [file-history] simplify file history pack creation code, check vg on being non-empty --- .../log/ui/history/FileHistoryFilterer.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/history/FileHistoryFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/history/FileHistoryFilterer.java index d6e3ae4c8170..1e408dc54893 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/history/FileHistoryFilterer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/history/FileHistoryFilterer.java @@ -72,23 +72,22 @@ class FileHistoryFilterer extends VcsLogFilterer { if (!myIndex.isIndexed(myRoot) || matchingCommits == null) { return super.createVisiblePack(dataPack, sortType, filters, matchingHeads, matchingCommits, canRequestMore); } + + VisibleGraph visibleGraph = createVisibleGraph(dataPack, sortType, matchingHeads, matchingCommits); + // I realize, I'm calculating this data for the second time. // No worries! It's going to be fine later! IndexDataGetter.FileNamesData namesData = myIndexDataGetter.buildFileNamesData(myFilePath); - if (!namesData.hasRenames()) { - VisibleGraph visibleGraph = createVisibleGraph(dataPack, sortType, matchingHeads, matchingCommits); - return new FileHistoryVisiblePack(dataPack, visibleGraph, canRequestMore, filters, namesData); - } + if (namesData.hasRenames() && visibleGraph.getVisibleCommitCount() > 0) { + if (visibleGraph instanceof VisibleGraphImpl) { - VisibleGraph visibleGraph = createVisibleGraph(dataPack, sortType, matchingHeads, matchingCommits); - if (visibleGraph instanceof VisibleGraphImpl) { - FileHistoryRefiner refiner = new FileHistoryRefiner(visibleGraph, namesData); - if (refiner.refine(((VisibleGraphImpl)visibleGraph).getLinearGraph(), getCurrentRow(dataPack, visibleGraph, namesData), myFilePath)) { - // creating a vg is the most expensive task, so trying to avoid that when unnecessary - return new FileHistoryVisiblePack(dataPack, createVisibleGraph(dataPack, sortType, matchingHeads, refiner.getMatchingCommits()), - canRequestMore, - filters, - namesData); + int row = getCurrentRow(dataPack, visibleGraph, namesData); + + FileHistoryRefiner refiner = new FileHistoryRefiner(visibleGraph, namesData); + if (refiner.refine(((VisibleGraphImpl)visibleGraph).getLinearGraph(), row, myFilePath)) { + // creating a vg is the most expensive task, so trying to avoid that when unnecessary + visibleGraph = createVisibleGraph(dataPack, sortType, matchingHeads, refiner.getMatchingCommits()); + } } }