From a3a064b4a5454a77208c13003bed3b495021c7be Mon Sep 17 00:00:00 2001 From: "andy.patterson" Date: Sat, 2 Jun 2018 18:09:18 -0400 Subject: [PATCH] perf: create single shared none instance Because all nones are equivalent, we can share a single instance. This should save a decent amount of memory and cpu cycles from not building the `None` class constantly. --- src/none.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/none.ts b/src/none.ts index f648f51..83c6b60 100644 --- a/src/none.ts +++ b/src/none.ts @@ -51,4 +51,5 @@ export default class None extends Maybe { asNullable(): T | null { return null; } } -export const none: () => Maybe = None.none; +const _noneSingleton = None.none(); +export const none = (): Maybe => _noneSingleton;