tuning - do not return from a valueOnOnWindDo block if possible.
--- a/WSensor.st Thu Feb 04 16:37:46 1999 +0100
+++ b/WSensor.st Fri Feb 05 00:13:09 1999 +0100
@@ -586,14 +586,11 @@
[ev notNil and:[ev isKeyEvent]] whileTrue:[
evKey := ev arguments at:1.
(evKey == aKey) ifTrue:[
- ev isKeyReleaseEvent ifTrue:[
- self nextEvent.
- ev := self pendingEvent.
- ] ifFalse:[
+ ev isKeyReleaseEvent ifFalse:[
n := n + 1.
- self nextEvent.
- ev := self pendingEvent.
- ]
+ ].
+ self nextEvent.
+ ev := self pendingEvent.
] ifFalse:[
ev := nil
]
@@ -620,17 +617,18 @@
|action|
action := [
- |nEvent "{ Class: SmallInteger }" anEvent|
-
- damage notNil ifTrue:[
- nEvent := anEventQueue size.
- 1 to:nEvent do:[:index |
- anEvent := anEventQueue at:index.
- anEvent notNil ifTrue:[
- (aView isNil or:[anEvent view == aView]) ifTrue:[
- (aCondition value:anEvent) ifTrue:[
- anEventQueue at:index put:nil
- ]
+ |nEvent "{ Class: SmallInteger }"
+ anEvent
+ queue|
+
+ queue := anEventQueue.
+ nEvent := queue size.
+ 1 to:nEvent do:[:index |
+ anEvent := queue at:index.
+ anEvent notNil ifTrue:[
+ (aView isNil or:[anEvent view == aView]) ifTrue:[
+ (aCondition value:anEvent) ifTrue:[
+ queue at:index put:nil
]
]
]
@@ -1751,16 +1749,18 @@
"retrieve the next damage (either expose or resize event)
or nil, if there is none. Remove it from the queue."
- |d foundOne|
+ |d|
damage size == 0 ifTrue:[^ nil].
- foundOne := false.
- [foundOne] whileFalse:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalDamageEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalDamageEventQueueAccess:[
+ |foundOne|
+
+ foundOne := false.
+ [foundOne] whileFalse:[
damage size == 0 ifTrue:[
foundOne := true
] ifFalse:[
@@ -1779,7 +1779,7 @@
Return if there are no damage events.
Remove it from the queue."
- |firstNonNilIndex|
+ |theEvent|
damage size == 0 ifTrue:[^ nil].
@@ -1787,34 +1787,36 @@
be careful: events are inserted at higher prio ...
"
self criticalDamageEventQueueAccess:[
- damage keysAndValuesDo:[:idx :anEvent |
+ |anEvent idx damageSize firstNonNilIndex|
+
+ idx := 1.
+ damageSize := damage size.
+ [idx <= damageSize] whileTrue:[
+ anEvent := damage at:idx.
anEvent notNil ifTrue:[
firstNonNilIndex isNil ifTrue:[
firstNonNilIndex := idx
].
(aViewOrNil isNil or:[anEvent view == aViewOrNil]) ifTrue:[
damage at:idx put:nil.
- firstNonNilIndex isNil ifTrue:[
- damage removeFromIndex:1 toIndex:idx
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
- ]
- ].
- ^ anEvent
+ theEvent := anEvent.
+ idx := damageSize.
].
].
+ idx := idx + 1.
].
- firstNonNilIndex isNil ifTrue:[
- damage removeAll
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
+ damageSize > 10 ifTrue:[
+ firstNonNilIndex isNil ifTrue:[
+ damage removeAll
+ ] ifFalse:[
+ firstNonNilIndex ~~ 1 ifTrue:[
+ damage removeFromIndex:1 toIndex:firstNonNilIndex
+ ]
]
]
].
- ^ nil
+ ^ theEvent
"Created: / 3.12.1998 / 13:41:49 / cg"
"Modified: / 3.2.1999 / 01:39:26 / cg"
@@ -1824,16 +1826,18 @@
"retrieve the next event or nil, if there is none.
Remove it from the queue."
- |e foundOne|
+ |e|
mouseAndKeyboard size == 0 ifTrue:[^ nil].
- foundOne := false.
- [foundOne] whileFalse:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalUserEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalUserEventQueueAccess:[
+ |foundOne|
+
+ foundOne := false.
+ [foundOne] whileFalse:[
mouseAndKeyboard size == 0 ifTrue:[
foundOne := true
] ifFalse:[
@@ -1852,7 +1856,7 @@
Return if there are no expose events.
Remove it from the queue."
- |firstNonNilIndex|
+ |theEvent|
damage size == 0 ifTrue:[^ nil].
@@ -1860,37 +1864,40 @@
be careful: events are inserted at higher prio ...
"
self criticalDamageEventQueueAccess:[
- damage keysAndValuesDo:[:idx :anEvent |
+ |firstNonNilIndex anEvent idx damageSize|
+
+ idx := 1.
+ damageSize := damage size.
+ [idx <= damageSize] whileTrue:[
+ anEvent := damage at:idx.
anEvent notNil ifTrue:[
firstNonNilIndex isNil ifTrue:[
firstNonNilIndex := idx
].
+
anEvent isDamage ifTrue:[
(aView isNil or:[anEvent view == aView]) ifTrue:[
+ theEvent := anEvent.
damage at:idx put:nil.
- firstNonNilIndex isNil ifTrue:[
- damage removeFromIndex:1 toIndex:idx
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
- ]
- ].
- ^ anEvent
+ idx := damageSize.
]
].
].
+ idx := idx + 1.
].
- firstNonNilIndex isNil ifTrue:[
- damage removeAll
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
+ damageSize > 10 ifTrue:[
+ firstNonNilIndex isNil ifTrue:[
+ damage removeAll
+ ] ifFalse:[
+ firstNonNilIndex ~~ 1 ifTrue:[
+ damage removeFromIndex:1 toIndex:firstNonNilIndex-1
+ ]
]
- ]
+ ].
].
- ^ nil
+ ^ theEvent
"Created: / 21.5.1996 / 17:20:54 / cg"
"Modified: / 3.2.1999 / 01:41:31 / cg"
@@ -1905,11 +1912,11 @@
mouseAndKeyboard size == 0 ifTrue:[^ nil].
- [e isNil] whileTrue:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalUserEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalUserEventQueueAccess:[
+ [e isNil] whileTrue:[
mouseAndKeyboard size == 0 ifTrue:[^ nil].
e := mouseAndKeyboard first.
@@ -2703,6 +2710,6 @@
!WindowSensor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Attic/WSensor.st,v 1.139 1999-02-03 00:41:43 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Attic/WSensor.st,v 1.140 1999-02-04 23:13:09 cg Exp $'
! !
WindowSensor initialize!
--- a/WindowSensor.st Thu Feb 04 16:37:46 1999 +0100
+++ b/WindowSensor.st Fri Feb 05 00:13:09 1999 +0100
@@ -586,14 +586,11 @@
[ev notNil and:[ev isKeyEvent]] whileTrue:[
evKey := ev arguments at:1.
(evKey == aKey) ifTrue:[
- ev isKeyReleaseEvent ifTrue:[
- self nextEvent.
- ev := self pendingEvent.
- ] ifFalse:[
+ ev isKeyReleaseEvent ifFalse:[
n := n + 1.
- self nextEvent.
- ev := self pendingEvent.
- ]
+ ].
+ self nextEvent.
+ ev := self pendingEvent.
] ifFalse:[
ev := nil
]
@@ -620,17 +617,18 @@
|action|
action := [
- |nEvent "{ Class: SmallInteger }" anEvent|
-
- damage notNil ifTrue:[
- nEvent := anEventQueue size.
- 1 to:nEvent do:[:index |
- anEvent := anEventQueue at:index.
- anEvent notNil ifTrue:[
- (aView isNil or:[anEvent view == aView]) ifTrue:[
- (aCondition value:anEvent) ifTrue:[
- anEventQueue at:index put:nil
- ]
+ |nEvent "{ Class: SmallInteger }"
+ anEvent
+ queue|
+
+ queue := anEventQueue.
+ nEvent := queue size.
+ 1 to:nEvent do:[:index |
+ anEvent := queue at:index.
+ anEvent notNil ifTrue:[
+ (aView isNil or:[anEvent view == aView]) ifTrue:[
+ (aCondition value:anEvent) ifTrue:[
+ queue at:index put:nil
]
]
]
@@ -1751,16 +1749,18 @@
"retrieve the next damage (either expose or resize event)
or nil, if there is none. Remove it from the queue."
- |d foundOne|
+ |d|
damage size == 0 ifTrue:[^ nil].
- foundOne := false.
- [foundOne] whileFalse:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalDamageEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalDamageEventQueueAccess:[
+ |foundOne|
+
+ foundOne := false.
+ [foundOne] whileFalse:[
damage size == 0 ifTrue:[
foundOne := true
] ifFalse:[
@@ -1779,7 +1779,7 @@
Return if there are no damage events.
Remove it from the queue."
- |firstNonNilIndex|
+ |theEvent|
damage size == 0 ifTrue:[^ nil].
@@ -1787,34 +1787,36 @@
be careful: events are inserted at higher prio ...
"
self criticalDamageEventQueueAccess:[
- damage keysAndValuesDo:[:idx :anEvent |
+ |anEvent idx damageSize firstNonNilIndex|
+
+ idx := 1.
+ damageSize := damage size.
+ [idx <= damageSize] whileTrue:[
+ anEvent := damage at:idx.
anEvent notNil ifTrue:[
firstNonNilIndex isNil ifTrue:[
firstNonNilIndex := idx
].
(aViewOrNil isNil or:[anEvent view == aViewOrNil]) ifTrue:[
damage at:idx put:nil.
- firstNonNilIndex isNil ifTrue:[
- damage removeFromIndex:1 toIndex:idx
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
- ]
- ].
- ^ anEvent
+ theEvent := anEvent.
+ idx := damageSize.
].
].
+ idx := idx + 1.
].
- firstNonNilIndex isNil ifTrue:[
- damage removeAll
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
+ damageSize > 10 ifTrue:[
+ firstNonNilIndex isNil ifTrue:[
+ damage removeAll
+ ] ifFalse:[
+ firstNonNilIndex ~~ 1 ifTrue:[
+ damage removeFromIndex:1 toIndex:firstNonNilIndex
+ ]
]
]
].
- ^ nil
+ ^ theEvent
"Created: / 3.12.1998 / 13:41:49 / cg"
"Modified: / 3.2.1999 / 01:39:26 / cg"
@@ -1824,16 +1826,18 @@
"retrieve the next event or nil, if there is none.
Remove it from the queue."
- |e foundOne|
+ |e|
mouseAndKeyboard size == 0 ifTrue:[^ nil].
- foundOne := false.
- [foundOne] whileFalse:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalUserEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalUserEventQueueAccess:[
+ |foundOne|
+
+ foundOne := false.
+ [foundOne] whileFalse:[
mouseAndKeyboard size == 0 ifTrue:[
foundOne := true
] ifFalse:[
@@ -1852,7 +1856,7 @@
Return if there are no expose events.
Remove it from the queue."
- |firstNonNilIndex|
+ |theEvent|
damage size == 0 ifTrue:[^ nil].
@@ -1860,37 +1864,40 @@
be careful: events are inserted at higher prio ...
"
self criticalDamageEventQueueAccess:[
- damage keysAndValuesDo:[:idx :anEvent |
+ |firstNonNilIndex anEvent idx damageSize|
+
+ idx := 1.
+ damageSize := damage size.
+ [idx <= damageSize] whileTrue:[
+ anEvent := damage at:idx.
anEvent notNil ifTrue:[
firstNonNilIndex isNil ifTrue:[
firstNonNilIndex := idx
].
+
anEvent isDamage ifTrue:[
(aView isNil or:[anEvent view == aView]) ifTrue:[
+ theEvent := anEvent.
damage at:idx put:nil.
- firstNonNilIndex isNil ifTrue:[
- damage removeFromIndex:1 toIndex:idx
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
- ]
- ].
- ^ anEvent
+ idx := damageSize.
]
].
].
+ idx := idx + 1.
].
- firstNonNilIndex isNil ifTrue:[
- damage removeAll
- ] ifFalse:[
- firstNonNilIndex ~~ 1 ifTrue:[
- damage removeFromIndex:1 toIndex:firstNonNilIndex
+ damageSize > 10 ifTrue:[
+ firstNonNilIndex isNil ifTrue:[
+ damage removeAll
+ ] ifFalse:[
+ firstNonNilIndex ~~ 1 ifTrue:[
+ damage removeFromIndex:1 toIndex:firstNonNilIndex-1
+ ]
]
- ]
+ ].
].
- ^ nil
+ ^ theEvent
"Created: / 21.5.1996 / 17:20:54 / cg"
"Modified: / 3.2.1999 / 01:41:31 / cg"
@@ -1905,11 +1912,11 @@
mouseAndKeyboard size == 0 ifTrue:[^ nil].
- [e isNil] whileTrue:[
- "
- be careful: events are inserted at higher prio ...
- "
- self criticalUserEventQueueAccess:[
+ "
+ be careful: events are inserted at higher prio ...
+ "
+ self criticalUserEventQueueAccess:[
+ [e isNil] whileTrue:[
mouseAndKeyboard size == 0 ifTrue:[^ nil].
e := mouseAndKeyboard first.
@@ -2703,6 +2710,6 @@
!WindowSensor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.139 1999-02-03 00:41:43 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.140 1999-02-04 23:13:09 cg Exp $'
! !
WindowSensor initialize!