From e9c80f036645caae7759b3954fc72dbe6c644edf Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 12 Aug 2016 07:46:18 +0200 Subject: [PATCH] some renamed in Map land --- src/vs/base/common/filters.ts | 4 ++-- src/vs/base/common/glob.ts | 4 ++-- src/vs/base/common/map.ts | 6 +++--- src/vs/base/common/strings.ts | 4 ++-- src/vs/base/test/common/map.test.ts | 14 +++++++------- src/vs/test/utils/instantiationTestUtils.ts | 6 +++--- .../parts/markers/common/markersModel.ts | 4 ++-- .../parts/search/browser/replaceService.ts | 4 ++-- .../workbench/parts/search/common/searchModel.ts | 16 ++++++++-------- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/vs/base/common/filters.ts b/src/vs/base/common/filters.ts index 3ae4b09aa5b..ad5585b7fe5 100644 --- a/src/vs/base/common/filters.ts +++ b/src/vs/base/common/filters.ts @@ -5,7 +5,7 @@ 'use strict'; import strings = require('vs/base/common/strings'); -import {LinkedMap} from 'vs/base/common/map'; +import {BoundedLinkedMap} from 'vs/base/common/map'; export interface IFilter { // Returns null if word doesn't match. @@ -299,7 +299,7 @@ export enum SubstringMatching { export const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matchesContiguousSubString); const fuzzySeparateFilter = or(matchesPrefix, matchesCamelCase, matchesSubString); -const fuzzyRegExpCache = new LinkedMap(10000); // bounded to 10000 elements +const fuzzyRegExpCache = new BoundedLinkedMap(10000); // bounded to 10000 elements export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching = false): IMatch[] { if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') { diff --git a/src/vs/base/common/glob.ts b/src/vs/base/common/glob.ts index 922b10c545d..2c91d0401cc 100644 --- a/src/vs/base/common/glob.ts +++ b/src/vs/base/common/glob.ts @@ -6,7 +6,7 @@ import strings = require('vs/base/common/strings'); import paths = require('vs/base/common/paths'); -import {LinkedMap} from 'vs/base/common/map'; +import {BoundedLinkedMap} from 'vs/base/common/map'; export interface IExpression { [pattern: string]: boolean | SiblingClause | any; @@ -222,7 +222,7 @@ interface IParsedPattern { trivia?: Trivia; } -const CACHE = new LinkedMap(10000); // bounded to 10000 elements +const CACHE = new BoundedLinkedMap(10000); // bounded to 10000 elements function parsePattern(pattern: string): IParsedPattern { if (!pattern) { diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index af4b2e52cf0..aaad604db4c 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -20,7 +20,7 @@ export interface Entry { * A simple map to store value by a key object. Key can be any object that has toString() function to get * string value of the key. */ -export class SimpleMap { +export class LinkedMap { protected map: { [key: string]: Entry }; protected _size: number; @@ -114,7 +114,7 @@ export class SimpleMap { * the cache will remove the entry that was last recently added. Or, if a ratio is provided below 1, * all elements will be removed until the ratio is full filled (e.g. 0.75 to remove 25% of old elements). */ -export class LinkedMap { +export class BoundedLinkedMap { protected map: { [key: string]: Entry }; private head: Entry; private tail: Entry; @@ -252,7 +252,7 @@ export class LinkedMap { * maximum number of elements in the cache, it helps to remove those * entries from the cache that are LRU. */ -export class LRUCache extends LinkedMap { +export class LRUCache extends BoundedLinkedMap { constructor(limit: number) { super(limit); diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index 69e8a96e8b8..043ebdd0c12 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import {LinkedMap} from 'vs/base/common/map'; +import {BoundedLinkedMap} from 'vs/base/common/map'; /** * The empty string. @@ -221,7 +221,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean { */ export let canNormalize = typeof (('').normalize) === 'function'; const nonAsciiCharactersPattern = /[^\u0000-\u0080]/; -const normalizedCache = new LinkedMap(10000); // bounded to 10000 elements +const normalizedCache = new BoundedLinkedMap(10000); // bounded to 10000 elements export function normalizeNFC(str: string): string { if (!canNormalize || !str) { return str; diff --git a/src/vs/base/test/common/map.test.ts b/src/vs/base/test/common/map.test.ts index 8e69710429d..25e796b2339 100644 --- a/src/vs/base/test/common/map.test.ts +++ b/src/vs/base/test/common/map.test.ts @@ -5,12 +5,12 @@ 'use strict'; -import {LinkedMap, LRUCache} from 'vs/base/common/map'; +import {BoundedLinkedMap, LRUCache} from 'vs/base/common/map'; import * as assert from 'assert'; suite('Map', () => { - test('LinkedMap - basics', function () { - const map = new LinkedMap(); + test('BoundedLinkedMap - basics', function () { + const map = new BoundedLinkedMap(); assert.equal(map.size, 0); @@ -66,8 +66,8 @@ suite('Map', () => { assert.ok(!map.has('1')); }); - test('LinkedMap - bounded', function () { - const map = new LinkedMap(5); + test('BoundedLinkedMap - bounded', function () { + const map = new BoundedLinkedMap(5); assert.equal(0, map.size); @@ -135,8 +135,8 @@ suite('Map', () => { assert.equal(map.get('14'), 14); }); - test('LinkedMap - bounded with ratio', function () { - const map = new LinkedMap(6, 0.5); + test('BoundedLinkedMap - bounded with ratio', function () { + const map = new BoundedLinkedMap(6, 0.5); assert.equal(0, map.size); diff --git a/src/vs/test/utils/instantiationTestUtils.ts b/src/vs/test/utils/instantiationTestUtils.ts index 84c12e4bd24..b9fc6d08040 100644 --- a/src/vs/test/utils/instantiationTestUtils.ts +++ b/src/vs/test/utils/instantiationTestUtils.ts @@ -5,7 +5,7 @@ import * as sinon from 'sinon'; import { TPromise } from 'vs/base/common/winjs.base'; -import { SimpleMap } from 'vs/base/common/map'; +import { LinkedMap } from 'vs/base/common/map'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; @@ -34,12 +34,12 @@ interface IServiceMock { export class TestInstantiationService extends InstantiationService { - private _servciesMap: SimpleMap, any>; + private _servciesMap: LinkedMap, any>; constructor(private _serviceCollection: ServiceCollection = new ServiceCollection()) { super(_serviceCollection); - this._servciesMap= new SimpleMap, any>(); + this._servciesMap= new LinkedMap, any>(); this._servciesMap.set(ITelemetryService, NullTelemetryService); this._servciesMap.set(IEventService, EventService); this._servciesMap.set(ISearchService, SearchService); diff --git a/src/vs/workbench/parts/markers/common/markersModel.ts b/src/vs/workbench/parts/markers/common/markersModel.ts index 979057ba0fc..8c81ce0d89a 100644 --- a/src/vs/workbench/parts/markers/common/markersModel.ts +++ b/src/vs/workbench/parts/markers/common/markersModel.ts @@ -88,14 +88,14 @@ export class FilterOptions { export class MarkersModel { - private markersByResource: Map.SimpleMap; + private markersByResource: Map.LinkedMap; private _filteredResources:Resource[]; private _nonFilteredResources:Resource[]; private _filterOptions:FilterOptions; constructor(markers: IMarker[]= []) { - this.markersByResource= new Map.SimpleMap(); + this.markersByResource= new Map.LinkedMap(); this._filterOptions= new FilterOptions(); this.update(markers); } diff --git a/src/vs/workbench/parts/search/browser/replaceService.ts b/src/vs/workbench/parts/search/browser/replaceService.ts index e879101ab92..9b70d08ac0e 100644 --- a/src/vs/workbench/parts/search/browser/replaceService.ts +++ b/src/vs/workbench/parts/search/browser/replaceService.ts @@ -25,11 +25,11 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; class EditorInputCache { - private cache: Map.SimpleMap>; + private cache: Map.LinkedMap>; constructor(private replaceService: ReplaceService, private editorService: IWorkbenchEditorService, private modelService: IModelService) { - this.cache= new Map.SimpleMap>(); + this.cache= new Map.LinkedMap>(); } public hasInput(fileMatch: FileMatch): boolean { diff --git a/src/vs/workbench/parts/search/common/searchModel.ts b/src/vs/workbench/parts/search/common/searchModel.ts index 52b64c291c9..c4643b63e6d 100644 --- a/src/vs/workbench/parts/search/common/searchModel.ts +++ b/src/vs/workbench/parts/search/common/searchModel.ts @@ -11,7 +11,7 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { TPromise, PPromise } from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; -import { SimpleMap } from 'vs/base/common/map'; +import { LinkedMap } from 'vs/base/common/map'; import { ArraySet } from 'vs/base/common/set'; import Event, { Emitter } from 'vs/base/common/event'; import * as Search from 'vs/platform/search/common/search'; @@ -100,7 +100,7 @@ export class FileMatch extends Disposable { private _resource: URI; private _model: IModel; private _modelListener: IDisposable; - private _matches: SimpleMap; + private _matches: LinkedMap; private _removedMatches: ArraySet; private _selectedMatch: Match; @@ -111,7 +111,7 @@ export class FileMatch extends Disposable { @IModelService private modelService: IModelService, @IReplaceService private replaceService: IReplaceService) { super(); this._resource = this.rawMatch.resource; - this._matches = new SimpleMap(); + this._matches = new LinkedMap(); this._removedMatches = new ArraySet(); this._updateScheduler = new RunOnceScheduler(this.updateMatches.bind(this), 250); @@ -172,7 +172,7 @@ export class FileMatch extends Disposable { if (!this._model) { return; } - this._matches = new SimpleMap(); + this._matches = new LinkedMap(); let matches = this._model .findMatches(this._query.pattern, this._model.getFullModelRange(), this._query.isRegExp, this._query.isCaseSensitive, this._query.isWordMatch); @@ -298,8 +298,8 @@ export class SearchResult extends Disposable { private _onChange = this._register(new Emitter()); public onChange: Event = this._onChange.event; - private _fileMatches: SimpleMap; - private _unDisposedFileMatches: SimpleMap; + private _fileMatches: LinkedMap; + private _unDisposedFileMatches: LinkedMap; private _query: Search.IPatternInfo = null; private _showHighlights: boolean; private _replacingAll: boolean = false; @@ -307,8 +307,8 @@ export class SearchResult extends Disposable { constructor(private _searchModel: SearchModel, @IReplaceService private replaceService: IReplaceService, @ITelemetryService private telemetryService: ITelemetryService, @IInstantiationService private instantiationService: IInstantiationService) { super(); - this._fileMatches = new SimpleMap(); - this._unDisposedFileMatches = new SimpleMap(); + this._fileMatches = new LinkedMap(); + this._unDisposedFileMatches = new LinkedMap(); } public set query(query: Search.IPatternInfo) { -- GitLab