#TUNING by cg
authorClaus Gittinger <cg@exept.de>
Thu, 30 Jun 2016 18:29:38 +0200
changeset 7397 11bd586c3a73
parent 7396 3b07bc3cfcb6
child 7398 6d085e759693
#TUNING by cg class: SimpleView comment/format in: #dependents #dependents: #dependentsDo: #noticeOfWindowClose changed:14 methods shortcut if dependents are nil
SimpleView.st
--- a/SimpleView.st	Fri Jun 24 17:54:08 2016 +0200
+++ b/SimpleView.st	Thu Jun 30 18:29:38 2016 +0200
@@ -21,16 +21,16 @@
 		lightColor bitGravity viewGravity controller windowGroup
 		preferredExtent explicitExtent dependents layoutManager
 		visibilityChannel helpKey dropTarget'
-	classVariableNames:'Grey CentPoint ViewSpacing DefaultStyle StyleSheet
-		DefaultViewBackgroundColor DefaultBorderColor DefaultLightColor
-		DefaultShadowColor DefaultBorderWidth DefaultFocusColor
-		DefaultFocusBorderWidth ReturnFocusWhenClosingModalBoxes
-		FlagOriginChanged FlagExtentChanged FlagCornerChanged
-		FlagExtentChangedBeforeCreated FlagCanTab
-		FlagRequestFocusOnPointerEnter
-		FlagDoNotRequestFocusOnPointerEnter FlagNativeWidget
-		FlagIsUnmappedModalBox FlagIsMDIChild FlagHiddenOnRealize
-		FlagHasExplicitExtent FlagTakeFocusWhenMapped FlagBeingDestroyed'
+	classVariableNames:'CentPoint DefaultBorderColor DefaultBorderWidth
+		DefaultFocusBorderWidth DefaultFocusColor DefaultLightColor
+		DefaultShadowColor DefaultStyle DefaultViewBackgroundColor
+		FlagBeingDestroyed FlagCanTab FlagCornerChanged
+		FlagDoNotRequestFocusOnPointerEnter FlagExtentChanged
+		FlagExtentChangedBeforeCreated FlagHasExplicitExtent
+		FlagHiddenOnRealize FlagIsMDIChild FlagIsUnmappedModalBox
+		FlagNativeWidget FlagOriginChanged FlagRequestFocusOnPointerEnter
+		FlagTakeFocusWhenMapped Grey ReturnFocusWhenClosingModalBoxes
+		StyleSheet ViewSpacing'
 	poolDictionaries:''
 	category:'Views-Basic'
 !
@@ -4900,7 +4900,7 @@
      Interface is provided mostly provided for ST80 compatibility;
      here, translate into ST/X's mechanism for telling others about this."
 
-    ^ self changed:#preferredExtent
+    dependents notNil ifTrue:[ self changed:#preferredExtent ]
 
     "Modified: 6.3.1997 / 16:12:02 / cg"
 !
@@ -5034,11 +5034,12 @@
 !
 
 dependents
-    "return a Collection of dependents"
+    "return a Collection of dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     dependents isNil ifTrue:[^ #()].
     dependents isCollection ifTrue:[
-	^ dependents
+        ^ dependents
     ].
     ^ IdentitySet with:dependents
 
@@ -5047,16 +5048,17 @@
 !
 
 dependents:aCollection
-    "set the collection of dependents"
+    "set the collection of dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     |dep|
 
     aCollection size == 1 ifTrue:[
-	dep := aCollection first.
-	dep isCollection ifFalse:[
-	    dependents := aCollection first.
-	    ^ self
-	]
+        dep := aCollection first.
+        dep isCollection ifFalse:[
+            dependents := aCollection first.
+            ^ self
+        ]
     ].
     dependents := aCollection
 
@@ -5065,17 +5067,18 @@
 !
 
 dependentsDo:aBlock
-    "evaluate aBlock for all of my dependents"
+    "evaluate aBlock for all of my dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     |deps|
 
     deps := dependents.
     deps notNil ifTrue:[
-	deps isCollection ifTrue:[
-	    deps do:aBlock
-	] ifFalse:[
-	    aBlock value:deps
-	]
+        deps isCollection ifTrue:[
+            deps do:aBlock
+        ] ifFalse:[
+            aBlock value:deps
+        ]
     ]
 
     "Created: 11.6.1997 / 13:10:51 / cg"
@@ -5958,7 +5961,7 @@
     ].
 
     originChanged ifTrue:[
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
     ].
 
     "Modified: / 10.10.2001 / 14:14:19 / cg"
@@ -6096,8 +6099,11 @@
     "view has been destroyed by someone else (usually window system)"
 
     shown ifTrue:[
-	shown := false.
-	self changed:#visibility.
+        shown := false.
+        dependents notNil ifTrue:[
+            self changed:#visibility.
+            self changed:#destroyed 
+        ].
     ].
     super destroyed
 
@@ -6422,7 +6428,7 @@
             ]
         ].
         shownBefore ~~ true ifTrue:[
-            self changed:#visibility.
+            dependents notNil ifTrue:[ self changed:#visibility ].
         ].
         self takeFocusWhenMapped ifTrue:[
             "/ this is a one-shot!!
@@ -6514,7 +6520,7 @@
     doRequestFocus ifTrue:[
         self requestFocus.
     ].
-    self changed:#pointerInView
+    dependents notNil ifTrue:[ self changed:#pointerInView ]
     
     "Modified: / 01-08-2012 / 17:06:41 / cg"
 !
@@ -6523,7 +6529,7 @@
     "mouse pointer left"
 
     super pointerLeave:buttonState.
-    self changed:#pointerInView
+    dependents notNil ifTrue:[ self changed:#pointerInView ]
 !
 
 propertyChange:propertyId state: state
@@ -6687,20 +6693,20 @@
     |wdgr|
 
     shown ifTrue:[
-	shown := false.
-	self changed:#visibility.
+        shown := false.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
     (wdgr := self windowGroup) notNil ifTrue:[
-	wdgr focusView == self ifTrue:[
-	    wdgr focusViewUnmapped.
-	].
+        wdgr focusView == self ifTrue:[
+            wdgr focusViewUnmapped.
+        ].
     ].
 
     subViews notNil ifTrue:[
-	subViews do:[:v |
-	    v containerUnmapped
-	].
-	self changed:#visibility.
+        subViews do:[:v |
+            v containerUnmapped
+        ].
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ]
 
     "Modified: 25.2.1997 / 22:40:52 / cg"
@@ -6716,7 +6722,7 @@
     newShown := how ~~ #fullyObscured.
     newShown ~~ shown ifTrue:[
         shown := newShown.
-        self changed:#visibility.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
 !
 
@@ -7595,14 +7601,14 @@
     "this one is sent, whenever contents changes its size -
      tell dependents about the change (i.e. scrollers)."
 
-    self changed:#sizeOfContents
+    dependents notNil ifTrue:[ self changed:#sizeOfContents ]
 !
 
 noticeOfWindowClose
     |app|
 
     (app := self application) notNil ifTrue:[
-	app noticeOfWindowClose:self
+        app noticeOfWindowClose:self
     ].
 !
 
@@ -7610,8 +7616,9 @@
     |app|
 
     (app := self application) notNil ifTrue:[
-	app noticeOfWindowOpen:self
-    ].
+        app noticeOfWindowOpen:self
+    ].
+    dependents notNil ifTrue:[ self changed:#opened ] 
 !
 
 originChanged:delta
@@ -7619,7 +7626,7 @@
      tell dependents (i.e. scrollers) about this"
 
     (delta = (0@0)) ifTrue:[^ self].
-    self changed:#originOfContents with:delta.
+    dependents notNil ifTrue:[ self changed:#originOfContents with:delta ].
 "/   subViews notNil ifTrue:[
 "/        subViews do:[:aSubView |
 "/            aSubView pixelOrigin:((aSubView left @ aSubView top) - delta)
@@ -7664,7 +7671,7 @@
     ].
     shown ifTrue:[
         shown := false.
-        self changed:#visibility.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
 
 "/    controller notNil ifTrue:[
@@ -7681,6 +7688,7 @@
     ].
     super destroy.
 
+    dependents notNil ifTrue:[ self changed:#destroyed ]. "/ must do before release, which clears the dependents
     self release.
 
 "/    superView isNil ifTrue:[
@@ -8610,7 +8618,7 @@
 
     ((newWidth == width) and:[newHeight == height]) ifTrue:[
         sameOrigin ifTrue:[^ self].
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
         ^ self pixelOrigin:origin
     ].
 
@@ -8754,7 +8762,7 @@
         ].
     ].
     sameOrigin ifFalse:[
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
     ].
 
     "Modified: / 25.5.1999 / 14:49:56 / cg"
@@ -10202,7 +10210,7 @@
 
         shown ifTrue:[
             shown := false.
-            self changed:#visibility.
+            dependents notNil ifTrue:[ self changed:#visibility ].
         ]
     ].