[ENH] speedup for DateAndTime>><

Ross Boylan RossBoylan at stanfordalumni.org
Sat Jul 3 05:45:04 UTC 2004


The following change to DateAndTime>>< makes a noticeable difference
in speed for me.  Note that the version of DateAndTime I'm working
with is not quite the same as the current one; I don't know if this
method has changed.

In words, I check if the offsets are the same, and if so, skip the
asUTC conversion, which is the expensive part of the operation.

Shifts in daylight savings time could cause the expensive branch to
kick in.  Probably the internal time should always be stored as UTC,
with the offset used just for display purposes.

< comparand

	| lutc rutc rhs|
	rhs _ comparand asDateAndTime.
	self offset == rhs offset ifTrue: [
		lutc _ self utc.
		rutc _ rhs utc.
	] ifFalse: 
	[
	lutc _ self asUTC utc.
	rutc _ rhs asUTC utc.
	].
	^lutc first < rutc first
	ifTrue: [ true ]
	ifFalse: 
	[
		lutc first > rutc first
		ifTrue: [ false ] 
		ifFalse: 
		[
			lutc second < rutc second
			ifTrue: [ true ] 
			ifFalse: 
			[
				lutc second > rutc second
				ifTrue: [ false ]
				ifFalse: 
				[
					lutc third < rutc third
				]
			]
		]
	]


I know this isn't a proper change set, or fileout, but my fileout from
the dual change sorter seems to be broken.



More information about the Squeak-dev mailing list