Skip to content

Commit 5766796

Browse files
Copilotalexr00
andcommitted
Optimize configuration reads by extracting helper method
- Extract getRecentlyUsedBranchesMaxCount() to avoid redundant config reads - Both getRecentlyUsedBranches() and saveRecentlyUsedBranch() now use the helper Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 226428b commit 5766796

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/github/createPRViewProvider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
134134
return repo.getRepoAccessAndMergeMethods(refetch);
135135
}
136136

137+
private getRecentlyUsedBranchesMaxCount(): number {
138+
return vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<number>(RECENTLY_USED_BRANCHES_COUNT, 5);
139+
}
140+
137141
protected getRecentlyUsedBranches(owner: string, repositoryName: string): string[] {
138-
const maxCount = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<number>(RECENTLY_USED_BRANCHES_COUNT, 5);
142+
const maxCount = this.getRecentlyUsedBranchesMaxCount();
139143
if (maxCount === 0) {
140144
return [];
141145
}
@@ -146,7 +150,7 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
146150
}
147151

148152
protected saveRecentlyUsedBranch(owner: string, repositoryName: string, branchName: string): void {
149-
const maxCount = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<number>(RECENTLY_USED_BRANCHES_COUNT, 5);
153+
const maxCount = this.getRecentlyUsedBranchesMaxCount();
150154
if (maxCount === 0) {
151155
return;
152156
}

0 commit comments

Comments
 (0)