reduce creation/destruction of NSDate objects

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32019 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-09 09:53:56 +00:00
parent 85a6f46fc2
commit ff39f70ab1
2 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2011-02-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSEvent.m: Avoid unneccessary creation/destruction of NSDate
instances during periodic events.
2011-02-08 Riccardo Mottola <rm@gnu.org>
* Source/NSBitmapImageRep+PNG.m:

View file

@ -64,6 +64,7 @@
* Class variables
*/
static NSString *timerKey = @"NSEventTimersKey";
static Class dateClass;
static Class eventClass;
/*
@ -74,6 +75,7 @@ static Class eventClass;
if (self == [NSEvent class])
{
[self setVersion: 3];
dateClass = [NSDate class];
eventClass = [NSEvent class];
}
}
@ -310,7 +312,7 @@ static Class eventClass;
NSTimeInterval timeInterval;
NSEvent *periodicEvent;
timeInterval = [[NSDate date] timeIntervalSinceReferenceDate];
timeInterval = [dateClass timeIntervalSinceReferenceDate];
periodicEvent = [self otherEventWithType: NSPeriodic
location: NSZeroPoint
modifierFlags: 0
@ -338,7 +340,7 @@ static Class eventClass;
NSTimeInterval timeInterval;
NSEvent *periodicEvent;
timeInterval = [[NSDate date] timeIntervalSinceReferenceDate];
timeInterval = [dateClass timeIntervalSinceReferenceDate];
periodicEvent = [self otherEventWithType: NSPeriodic
location: NSZeroPoint
modifierFlags: 0