unnecessary zero fill and nil out

Yoshiki Ohshima ohshima at is.titech.ac.jp
Tue Sep 12 02:37:29 UTC 2000


  Hi,

  I found that many unnecessary zero-fills and nil-outs are
(still) carried out at runtime.  For instance, a #copy
message to String, which is popular operation, could be
faster if String implements #shallowCopy something like:

     shallowCopy
         ^self clone.

   In fact, it is almost twice faster than the current
implementation that clears the all elements zero before
storing actual bytes.

  the same thing is applicable to almost every
SequensableCollections.  Copying (or deepCopying) Form
(Bitmap), Array, etc. become 50% faster on my laptop with
the optimization.

  Attached is a change set for this.  I avoid to change the
behavior of #copy to a OrderedCollection and RunArray, but
optimizing this would be effective to the overall
performance.

  More general solution to eliminate unnecessary nil-out is
difficult.  But one aproximation of this would be a instance
creation primitive for bit object that doesn't do nil-out.

  Thanks,

  -- Yoshiki
-------------- next part --------------
'From Squeak2.8 of 13 June 2000 [latest update: #2359] on 11 September 2000 at 7:18:55 pm'!

!SequenceableCollection methodsFor: 'copying' stamp: 'yo 9/11/2000 18:58'!
shallowCopy
	^self tryClone
! !

!SequenceableCollection methodsFor: 'copying' stamp: 'yo 9/11/2000 18:56'!
tryClone
	^self clone! !


!OrderedCollection methodsFor: 'copying' stamp: 'yo 9/11/2000 18:58'!
tryClone
	^self copyFrom: 1 to: self size! !


!RunArray methodsFor: 'copying' stamp: 'yo 9/11/2000 18:57'!
tryClone
	^self copyFrom: 1 to: self size.! !



More information about the Squeak-dev mailing list