From 6b8ba601bcab7db90ec5c3ced80376e53fdc9a79 Mon Sep 17 00:00:00 2001 From: mccallum Date: Mon, 18 Mar 1996 18:31:37 +0000 Subject: [PATCH] ([NSDate +distantFuture]): Increase efficiency by caching a single instance in a static variable. ([NSDate +distantPast]): Likewise. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1184 72102866-910b-0410-8b05-ffd578937521 --- Source/NSDate.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/NSDate.m b/Source/NSDate.m index 470ecea2d..fd262575d 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -164,12 +164,18 @@ + (NSDate*) distantFuture { - return [self dateWithTimeIntervalSinceReferenceDate: DISTANT_FUTURE]; + static id df = nil; + if (!df) + df = [[self alloc] initWithTimeIntervalSinceReferenceDate: DISTANT_FUTURE]; + return df; } + (NSDate*) distantPast { - return [self dateWithTimeIntervalSinceReferenceDate: DISTANT_PAST]; + static id dp = nil; + if (!dp) + dp = [[self alloc] initWithTimeIntervalSinceReferenceDate: DISTANT_PAST]; + return dp; } - (id) init