Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/base/common/arrays.ts')
-rw-r--r--src/vs/base/common/arrays.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vs/base/common/arrays.ts b/src/vs/base/common/arrays.ts
index b567c8fe977..d543fdd8f83 100644
--- a/src/vs/base/common/arrays.ts
+++ b/src/vs/base/common/arrays.ts
@@ -47,6 +47,18 @@ export function equals<T>(one: ReadonlyArray<T> | undefined, other: ReadonlyArra
}
/**
+ * Remove the element at `index` by replacing it with the last element. This is faster than `splice`
+ * but changes the order of the array
+ */
+export function removeFastWithoutKeepingOrder<T>(array: T[], index: number) {
+ const last = array.length - 1;
+ if (index < last) {
+ array[index] = array[last];
+ }
+ array.pop();
+}
+
+/**
* Performs a binary search algorithm over a sorted array.
*
* @param array The array being searched.