@@ -13,6 +13,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
13
13
import { InstantiationType , registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
14
14
import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
15
15
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
16
+ import { MRUCache } from 'vs/base/common/map' ;
16
17
17
18
interface ICustomEditorLabelObject {
18
19
readonly [ key : string ] : string ;
@@ -39,6 +40,8 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
39
40
private patterns : ICustomEditorLabelPattern [ ] = [ ] ;
40
41
private enabled = true ;
41
42
43
+ private cache = new MRUCache < URI , string > ( 3 ) ;
44
+
42
45
constructor (
43
46
@IConfigurationService private readonly configurationService : IConfigurationService ,
44
47
@IWorkspaceContextService private readonly workspaceContextService : IWorkspaceContextService ,
@@ -115,7 +118,18 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
115
118
if ( ! this . enabled ) {
116
119
return undefined ;
117
120
}
118
- return this . applyPatterns ( resource ) ;
121
+
122
+ const cached = this . cache . get ( resource ) ;
123
+ if ( cached !== undefined ) {
124
+ return cached ;
125
+ }
126
+
127
+ const result = this . applyPatterns ( resource ) ;
128
+ if ( result !== undefined ) {
129
+ this . cache . set ( resource , result ) ;
130
+ }
131
+
132
+ return result ;
119
133
}
120
134
121
135
private applyPatterns ( resource : URI ) : string | undefined {
0 commit comments