mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-15 23:05:41 +00:00
Change Runnable.bin -> Runnable.kind
As per matklad, we now pass the responsibility for finding the binary to the frontend. Also, added caching for finding the binary path to reduce the amount of filesystem interactions.
This commit is contained in:
parent
a419cedb1c
commit
d605ec9c32
13 changed files with 133 additions and 93 deletions
|
@ -99,3 +99,21 @@ export function isValidExecutable(path: string): boolean {
|
|||
export function setContextValue(key: string, value: any): Thenable<void> {
|
||||
return vscode.commands.executeCommand('setContext', key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a higher-order function that caches the results of invoking the
|
||||
* underlying function.
|
||||
*/
|
||||
export function memoize<Ret, TThis, Param extends string>(func: (this: TThis, arg: Param) => Ret) {
|
||||
const cache = new Map<string, Ret>();
|
||||
|
||||
return function(this: TThis, arg: Param) {
|
||||
const cached = cache.get(arg);
|
||||
if (cached) return cached;
|
||||
|
||||
const result = func.call(this, arg);
|
||||
cache.set(arg, result);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue