From e0ec838fb564bc5cab4384c813a74be6d6e4aacd Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 23 Jun 2010 12:58:47 +0400 Subject: [PATCH] Git: git users component to exit faster --- .../git4idea/history/GitUsersComponent.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitUsersComponent.java b/plugins/git4idea/src/git4idea/history/GitUsersComponent.java index 795783edf2bc..8c289b6197f5 100644 --- a/plugins/git4idea/src/git4idea/history/GitUsersComponent.java +++ b/plugins/git4idea/src/git4idea/history/GitUsersComponent.java @@ -124,13 +124,15 @@ public class GitUsersComponent { final Map toUpdate = new HashMap(); for (Pair pair : copy.values()) { + atomicSectionsAware.checkShouldExit(); + final String key = pair.getFirst(); UsersData data = myState.get(key); if (data == null) { data = new UsersData(); data.forceUpdate(); } - if (data.load(pair.getSecond())) { + if (data.load(pair.getSecond(), atomicSectionsAware)) { toUpdate.put(key, data); } } @@ -270,7 +272,7 @@ public class GitUsersComponent { myUsers.addAll(users); } - public boolean load(final LowLevelAccess lowLevelAccess) { + public boolean load(final LowLevelAccess lowLevelAccess, final AtomicSectionsAware atomicSectionsAware) { if (HeavyProcessLatch.INSTANCE.isRunning()) return false; HeavyProcessLatch.INSTANCE.processStarted(); @@ -279,11 +281,11 @@ public class GitUsersComponent { boolean result = false; if ((! myStartReached) && (myForceUpdate || myEarlierDate.isTimeToUpdate(ourBackInterval))) { result = true; - lookBack(lowLevelAccess, newData); + lookBack(lowLevelAccess, newData, atomicSectionsAware); } if (myForceUpdate || myCloserDate.isTimeToUpdate(ourForwardInterval)) { result = true; - lookForward(lowLevelAccess, newData); + lookForward(lowLevelAccess, newData, atomicSectionsAware); } myForceUpdate = false; @@ -302,23 +304,29 @@ public class GitUsersComponent { Collections.sort(myUsers); } - private void lookForward(LowLevelAccess lowLevelAccess, Set newData) { + private void lookForward(LowLevelAccess lowLevelAccess, Set newData, AtomicSectionsAware atomicSectionsAware) { myCloserDate.updateTs(); - loadImpl(lowLevelAccess, newData, null, new Date(myCloserDate.getT())); + loadImpl(lowLevelAccess, newData, null, new Date(myCloserDate.getT()), atomicSectionsAware); } - private void lookBack(LowLevelAccess lowLevelAccess, Set newData) { + private void lookBack(LowLevelAccess lowLevelAccess, Set newData, AtomicSectionsAware atomicSectionsAware) { myEarlierDate.updateTs(); - loadImpl(lowLevelAccess, newData, new Date(myEarlierDate.getT()), null); + loadImpl(lowLevelAccess, newData, new Date(myEarlierDate.getT()), null, atomicSectionsAware); } - private void loadImpl(LowLevelAccess lowLevelAccess, final Set newData, @Nullable final Date before, @Nullable final Date after) { + private void loadImpl(LowLevelAccess lowLevelAccess, + final Set newData, + @Nullable final Date before, + @Nullable final Date after, + final AtomicSectionsAware atomicSectionsAware) { try { final Ref beforeTick = new Ref(Long.MAX_VALUE); // min final Ref afterTick = new Ref(-1L); // max lowLevelAccess.loadCommits(Collections.emptyList(), before, after, Collections.emptyList(), new Consumer() { public void consume(GitCommit gitCommit) { + atomicSectionsAware.checkShouldExit(); + final long time = gitCommit.getDate().getTime(); beforeTick.set(Math.min(beforeTick.get(), time)); afterTick.set(Math.max(afterTick.get(), time));