Skip to content

Commit ed13900

Browse files
committed
(refactor) avoid querying the repo multiple times when generating branch commands
1 parent 282e578 commit ed13900

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/branchlist.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ impl Component for BranchListComponent {
115115
out.clear();
116116
}
117117

118+
let selection_is_cur_branch =
119+
self.selection_is_cur_branch();
120+
118121
out.push(CommandInfo::new(
119122
strings::commands::scroll(&self.key_config),
120123
true,
@@ -139,7 +142,7 @@ impl Component for BranchListComponent {
139142
strings::commands::compare_with_head(
140143
&self.key_config,
141144
),
142-
!self.selection_is_cur_branch(),
145+
!selection_is_cur_branch,
143146
true,
144147
));
145148

@@ -156,8 +159,7 @@ impl Component for BranchListComponent {
156159
strings::commands::select_branch_popup(
157160
&self.key_config,
158161
),
159-
!self.selection_is_cur_branch()
160-
&& self.valid_selection(),
162+
!selection_is_cur_branch && self.valid_selection(),
161163
true,
162164
));
163165

@@ -173,23 +175,23 @@ impl Component for BranchListComponent {
173175
strings::commands::delete_branch_popup(
174176
&self.key_config,
175177
),
176-
!self.selection_is_cur_branch(),
178+
!selection_is_cur_branch,
177179
true,
178180
));
179181

180182
out.push(CommandInfo::new(
181183
strings::commands::merge_branch_popup(
182184
&self.key_config,
183185
),
184-
!self.selection_is_cur_branch(),
186+
!selection_is_cur_branch,
185187
true,
186188
));
187189

188190
out.push(CommandInfo::new(
189191
strings::commands::branch_popup_rebase(
190192
&self.key_config,
191193
),
192-
!self.selection_is_cur_branch(),
194+
!selection_is_cur_branch,
193195
true,
194196
));
195197

0 commit comments

Comments
 (0)