Skip to content

Commit d78fc30

Browse files
committed
reduce redundancy
1 parent 6ce3dbc commit d78fc30

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/managers/common/fastPath.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,24 @@ export async function tryFastPathGet(opts: FastPathOptions): Promise<FastPathRes
102102
try {
103103
const resolved = await opts.resolve(persistedPath);
104104
if (resolved) {
105-
if (isGlobalScope && cacheStopWatch) {
106-
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch.elapsedTime, {
105+
if (isGlobalScope) {
106+
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch!.elapsedTime, {
107107
managerLabel: opts.label,
108108
result: 'hit',
109109
});
110110
}
111111
return { env: resolved };
112112
}
113113
// Cached path found but resolve returned undefined (e.g., Python was uninstalled)
114-
if (isGlobalScope && cacheStopWatch) {
115-
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch.elapsedTime, {
114+
if (isGlobalScope) {
115+
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch!.elapsedTime, {
116116
managerLabel: opts.label,
117117
result: 'stale',
118118
});
119119
}
120120
} catch (err) {
121-
if (isGlobalScope && cacheStopWatch) {
122-
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch.elapsedTime, {
121+
if (isGlobalScope) {
122+
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch!.elapsedTime, {
123123
managerLabel: opts.label,
124124
result: 'stale',
125125
});
@@ -130,8 +130,8 @@ export async function tryFastPathGet(opts: FastPathOptions): Promise<FastPathRes
130130
);
131131
}
132132
} else {
133-
if (isGlobalScope && cacheStopWatch) {
134-
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch.elapsedTime, {
133+
if (isGlobalScope) {
134+
sendTelemetryEvent(EventNames.GLOBAL_ENV_CACHE, cacheStopWatch!.elapsedTime, {
135135
managerLabel: opts.label,
136136
result: 'miss',
137137
});

0 commit comments

Comments
 (0)