-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
environments.known
API faster (microsoft/vscode-python#23010)
Closes microsoft/vscode-python#22994 closes microsoft/vscode-python#22993 Temporarily build our own known cache from which we return envs instead.
- Loading branch information
Kartik Raj
authored
Mar 1, 2024
1 parent
0100536
commit 2da5b7f
Showing
4 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
extensions/positron-python/src/client/environmentKnownCache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { Environment } from './api/types'; | ||
|
||
/** | ||
* Workaround temp cache until types are consolidated. | ||
*/ | ||
export class EnvironmentKnownCache { | ||
private _envs: Environment[] = []; | ||
|
||
constructor(envs: Environment[]) { | ||
this._envs = envs; | ||
} | ||
|
||
public get envs(): Environment[] { | ||
return this._envs; | ||
} | ||
|
||
public addEnv(env: Environment): void { | ||
const found = this._envs.find((e) => env.id === e.id); | ||
if (!found) { | ||
this._envs.push(env); | ||
} | ||
} | ||
|
||
public updateEnv(oldValue: Environment, newValue: Environment | undefined): void { | ||
const index = this._envs.findIndex((e) => oldValue.id === e.id); | ||
if (index !== -1) { | ||
if (newValue === undefined) { | ||
this._envs.splice(index, 1); | ||
} else { | ||
this._envs[index] = newValue; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters