Skip to content

Commit d2bc3a0

Browse files
committed
remove unused and duplicated code
1 parent 66bcd33 commit d2bc3a0

4 files changed

Lines changed: 3 additions & 25 deletions

File tree

src/vs/base/common/collections.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ export function forEach<T>(from: IStringDictionary<T> | INumberDictionary<T>, ca
7171
}
7272
}
7373

74-
/**
75-
* Removes an element from the dictionary. Returns {{false}} if the property
76-
* does not exists.
77-
*/
78-
export function remove<T>(from: IStringDictionary<T> | INumberDictionary<T>, key: string): boolean {
79-
if (!hasOwnProperty.call(from, key)) {
80-
return false;
81-
}
82-
delete (from as any)[key];
83-
return true;
84-
}
85-
8674
/**
8775
* Groups the collection into a dictionary based on the provided
8876
* group function.

src/vs/base/common/objects.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function equals(one: any, other: any): boolean {
171171
return true;
172172
}
173173

174-
export function arrayToHash(array: any[]) {
174+
function arrayToHash(array: string[]): { [name: string]: true } {
175175
const result: any = {};
176176
for (let i = 0; i < array.length; ++i) {
177177
result[array[i]] = true;
@@ -218,11 +218,6 @@ export function safeStringify(obj: any): string {
218218
});
219219
}
220220

221-
export function getOrDefault<T, R>(obj: T, fn: (obj: T) => R, defaultValue: R | null = null): R | null {
222-
const result = fn(obj);
223-
return typeof result === 'undefined' ? defaultValue : result;
224-
}
225-
226221
export function getOrDefault2<T, R>(obj: T, fn: (obj: T) => R | undefined, defaultValue: R): R {
227222
const result = fn(obj);
228223
return typeof result === 'undefined' ? defaultValue : result;

src/vs/base/test/common/collections.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,4 @@ suite('Collections', () => {
5454
assert.equal(grouped[group2].length, 1);
5555
assert.equal(grouped[group2][0].value, value3);
5656
});
57-
58-
test('remove', () => {
59-
assert(collections.remove({ 'far': 1 }, 'far'));
60-
assert(!collections.remove({ 'far': 1 }, 'boo'));
61-
});
6257
});

src/vs/platform/extensionManagement/node/extensionGalleryService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { distinct } from 'vs/base/common/arrays';
99
import { getErrorMessage, isPromiseCanceledError, canceled } from 'vs/base/common/errors';
1010
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionManifest, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation } from 'vs/platform/extensionManagement/common/extensionManagement';
1111
import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
12-
import { assign, getOrDefault } from 'vs/base/common/objects';
12+
import { assign, getOrDefault2 } from 'vs/base/common/objects';
1313
import { IRequestService } from 'vs/platform/request/node/request';
1414
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1515
import { IPager } from 'vs/base/common/paging';
@@ -402,7 +402,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
402402

403403
const type = options.names ? 'ids' : (options.text ? 'text' : 'all');
404404
let text = options.text || '';
405-
const pageSize = getOrDefault(options, o => o.pageSize, 50);
405+
const pageSize = getOrDefault2(options, o => o.pageSize, 50);
406406

407407
/* __GDPR__
408408
"galleryService:query" : {

0 commit comments

Comments
 (0)