summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/freelist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/internal/freelist.ts')
-rw-r--r--ext/node/polyfills/internal/freelist.ts30
1 files changed, 0 insertions, 30 deletions
diff --git a/ext/node/polyfills/internal/freelist.ts b/ext/node/polyfills/internal/freelist.ts
deleted file mode 100644
index 8faba8e68..000000000
--- a/ext/node/polyfills/internal/freelist.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-
-type Fn<T> = (...args: unknown[]) => T;
-export class FreeList<T> {
- name: string;
- ctor: Fn<T>;
- max: number;
- list: Array<T>;
- constructor(name: string, max: number, ctor: Fn<T>) {
- this.name = name;
- this.ctor = ctor;
- this.max = max;
- this.list = [];
- }
-
- alloc(): T {
- return this.list.length > 0
- ? this.list.pop()
- : Reflect.apply(this.ctor, this, arguments);
- }
-
- free(obj: T) {
- if (this.list.length < this.max) {
- this.list.push(obj);
- return true;
- }
- return false;
- }
-}