FogBugz (Case [Issue]20088) Kernel - Improve speed of Character>>isSeparator in when the separator is not a space

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FogBugz (Case [Issue]20088) Kernel - Improve speed of Character>>isSeparator in when the separator is not a space

Pharo Issue Tracker
FogBugz Notification
avatar
Enhancement in Project:  Kernel: 1. Pharo Image  •  You are subscribed to this case
The current implementation of #isSeparator is:

isSeparator
self asInteger = 32
ifTrue: [ ^ true ].
self asInteger = 13
ifTrue: [ ^ true ].
self asInteger = 9
ifTrue: [ ^ true ].
self asInteger = 10
ifTrue: [ ^ true ].
self asInteger = 12
ifTrue: [ ^ true ].
^ false

I propose to change it to:

isSeparator
| in |
^ (in := self asInteger) == 32 or: [ in == 13 or: [ in == 9 or: [ in == 10 or: [ in == 12 ] ] ] ]

Here are the bench I got:

"Current version"
character := 32 asCharacter.
[ character isSeparator ] bench. "'114,652,343 per second'"

character := 12 asCharacter.
[ character isSeparator ] bench. "'52,220,976 per second'"

"New version"
character := 32 asCharacter.
[ character isSeparator ] bench. "'116,128,815 per second'"

character := 12 asCharacter.
[ character isSeparator ] bench. "'99,641,823 per second'"

Also I would like to add this test:

testIsSeparator
{Character space.
Character cr.
Character lf.
Character newPage.
Character tab} do: [ :each | self assert: each isSeparator ].
Character alphabet do: [ :each | self deny: each isSeparator ]

If no one complains I'll do it in Pharo 7
Priority Priority: 5 – Fix If Time Status Status: Work Needed
Assigned To Assigned to: Everyone Milestone Milestone: Pharo7.0

Go to Case
No longer need updates? Unsubscribe from this case.

Don't want FogBugz notifications anymore? Update your preferences.

FogBugz

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
https://lists.gforge.inria.fr/mailman/listinfo/pharo-bugtracker