Skip to content

Commit 0500e35

Browse files
Fix performance issue related to determining whether branches are remote tracking branches
Signed-off-by: Jacob Stopak <[email protected]>
1 parent 2696cb9 commit 0500e35

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

git_sim/git_sim_base_command.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,17 @@ def draw_branch(self, commit, i, make_branches_remote=False):
467467

468468
for branch in branches:
469469
if (
470-
not self.is_remote_tracking_branch(branch) # local branch
470+
branch not in remote_tracking_branches # local branch
471471
and commit.hexsha == self.repo.heads[branch].commit.hexsha
472472
) or (
473-
self.is_remote_tracking_branch(branch) # remote tracking branch
473+
branch in remote_tracking_branches # remote tracking branch
474474
and commit.hexsha == remote_tracking_branches[branch]
475475
):
476476
text = (
477477
(make_branches_remote + "/" + branch)
478478
if (
479479
make_branches_remote
480-
and not self.is_remote_tracking_branch(branch)
480+
and branch not in remote_tracking_branches
481481
)
482482
else branch
483483
)
@@ -1178,15 +1178,6 @@ def get_remote_tracking_branches(self):
11781178
remote_tracking_branches[ref.name] = ref.commit.hexsha
11791179
return remote_tracking_branches
11801180

1181-
def is_remote_tracking_branch(self, branch):
1182-
remote_refs = [remote.refs for remote in self.repo.remotes]
1183-
remote_tracking_branches = {}
1184-
for reflist in remote_refs:
1185-
for ref in reflist:
1186-
if "HEAD" not in ref.name and ref.name not in remote_tracking_branches:
1187-
remote_tracking_branches[ref.name] = ref.commit.hexsha
1188-
return branch in remote_tracking_branches
1189-
11901181
def create_zone_text(
11911182
self,
11921183
firstColumnFileNames,

0 commit comments

Comments
 (0)