Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1124.mcz ==================== Summary ==================== Name: Morphic-mt.1124 Author: mt Time: 29 April 2016, 1:04:05.656719 pm UUID: 20b80e2e-df90-fa43-bf17-339878efb46a Ancestors: Morphic-cmm.1123 Speeds up drawing of large tree morphs by introducing a cache for the width of each column. Invalidate that cache each time the nodes in the tree are re-layouted. Try out "CompiledMethod allInstances explore" before and after this change. Have "PluggableListMorph highlightHoveredRow: true". Why? Computation of largest item in a column is O(n) at the moment. Drawing code needs width of column to position the strings in each row. Each row is a (string) morph and the columns are "faked". =============== Diff against Morphic-cmm.1123 =============== Item was changed: ----- Method: IndentingListItemMorph>>widthOfColumn: (in category 'accessing - columns') ----- widthOfColumn: columnIndex | widthOrSpec | container columns ifNil: [ ^ self width ]. + (container columnsCache at: columnIndex) + ifNotNil: [ :cachedWidth | ^ cachedWidth ]. widthOrSpec := container columns at: columnIndex. + container columnsCache at: columnIndex put: (widthOrSpec isNumber - ^ widthOrSpec isNumber ifTrue: [ widthOrSpec ] ifFalse: [ widthOrSpec isBlock ifTrue: [ widthOrSpec cull: container cull: self ] ifFalse: [ widthOrSpec ifNil: [ self width ] ifNotNil: [ "Fall back" + 50 ] ] ]). + ^ container columnsCache at: columnIndex! - 50 ] ] ]! Item was changed: ScrollPane subclass: #SimpleHierarchicalListMorph + instanceVariableNames: 'selectedMorph hoveredMorph getListSelector keystrokeActionSelector autoDeselect columns columnsCache sortingSelector getSelectionSelector setSelectionSelector potentialDropMorph lineColor' - instanceVariableNames: 'selectedMorph hoveredMorph getListSelector keystrokeActionSelector autoDeselect columns sortingSelector getSelectionSelector setSelectionSelector potentialDropMorph lineColor' classVariableNames: 'WrappedNavigation' poolDictionaries: '' category: 'Morphic-Explorer'! SimpleHierarchicalListMorph class instanceVariableNames: 'expandedForm notExpandedForm'! !SimpleHierarchicalListMorph commentStamp: 'ls 3/1/2004 12:15' prior: 0! Display a hierarchical list of items. Each item should be wrapped with a ListItemWrapper. For a simple example, look at submorphsExample. For beefier examples, look at ObjectExplorer or FileList2.! SimpleHierarchicalListMorph class instanceVariableNames: 'expandedForm notExpandedForm'! Item was changed: ----- Method: SimpleHierarchicalListMorph>>adjustSubmorphPositions (in category 'private') ----- adjustSubmorphPositions | p | p := 0@0. scroller submorphsDo: [ :each | | h | each visible ifTrue: [ h := each height. each privateBounds: (p extent: self preferredSubmorphWidth@h). p := p + (0@h) ]]. self + clearColumnsCache; changed; layoutChanged; setScrollDeltas. ! Item was added: + ----- Method: SimpleHierarchicalListMorph>>clearColumnsCache (in category 'private - caching') ----- + clearColumnsCache + + columnsCache := self columns + ifNil: [Array empty] + ifNotNil: [:c | Array new: c size].! Item was added: + ----- Method: SimpleHierarchicalListMorph>>columnsCache (in category 'private - caching') ----- + columnsCache + columnsCache ifNil: [self clearColumnsCache]. + ^ columnsCache! Item was changed: ----- Method: SimpleHierarchicalListMorph>>drawLinesOn: (in category 'drawing') ----- drawLinesOn: aCanvas | lColor | lColor := self lineColor. aCanvas transformBy: scroller transform clippingTo: scroller innerBounds during:[:clippedCanvas | + scroller submorphsDo: [ :submorph | + (submorph visible and: [(submorph isExpanded + or: [clippedCanvas isVisible: submorph fullBounds] ) + or: [ submorph nextSibling notNil and: [clippedCanvas isVisible: submorph nextSibling fullBounds]]]) + ifTrue: [submorph drawLinesOn: clippedCanvas lineColor: lColor indentThreshold: 0] ] ] - scroller submorphs - select: [:submorph | submorph visible] - thenDo: [ :submorph | - ((submorph isExpanded - or: [clippedCanvas isVisible: submorph fullBounds] ) - or: [ submorph nextSibling notNil and: [clippedCanvas isVisible: submorph nextSibling bounds]]) - ifTrue: [submorph drawLinesOn: clippedCanvas lineColor: lColor indentThreshold: 0] ] ] smoothing: scroller smoothing. ! |
On Fri, 29 Apr 2016, [hidden email] wrote:
> Marcel Taeumel uploaded a new version of Morphic to project The Trunk: > http://source.squeak.org/trunk/Morphic-mt.1124.mcz > > ==================== Summary ==================== > > Name: Morphic-mt.1124 > Author: mt > Time: 29 April 2016, 1:04:05.656719 pm > UUID: 20b80e2e-df90-fa43-bf17-339878efb46a > Ancestors: Morphic-cmm.1123 > > Speeds up drawing of large tree morphs by introducing a cache for the width of each column. Invalidate that cache each time the nodes in the tree are re-layouted. > > Try out "CompiledMethod allInstances explore" before and after this change. Have "PluggableListMorph highlightHoveredRow: true". > > Why? Computation of largest item in a column is O(n) at the moment. Drawing code needs width of column to position the strings in each row. Each row is a (string) morph and the columns are "faked". > > =============== Diff against Morphic-cmm.1123 =============== > > Item was changed: > ----- Method: IndentingListItemMorph>>widthOfColumn: (in category 'accessing - columns') ----- > widthOfColumn: columnIndex > | widthOrSpec | > container columns ifNil: [ ^ self width ]. > + (container columnsCache at: columnIndex) > + ifNotNil: [ :cachedWidth | ^ cachedWidth ]. > widthOrSpec := container columns at: columnIndex. > + container columnsCache at: columnIndex put: (widthOrSpec isNumber > - ^ widthOrSpec isNumber > ifTrue: [ widthOrSpec ] > ifFalse: > [ widthOrSpec isBlock > ifTrue: > [ widthOrSpec > cull: container > cull: self ] > ifFalse: > [ widthOrSpec > ifNil: [ self width ] > ifNotNil: [ "Fall back" > + 50 ] ] ]). > + ^ container columnsCache at: columnIndex! Why do a lookup when the previous expression returns the same value? Levente |
Hi Levente,
what do you refer to? The width for a column will be computed only once now and then accessed only. Best, Marcel |
2016-04-29 20:49 GMT+02:00 marcel.taeumel <[hidden email]>: Hi Levente, Hi Marcel, at:put: will answer the put object. So rather than self at: key put: value. ^self at: key you can ^self at: key put: value
|
Ah, of course. Thanks for the pointer.
Best, Marcel |
Free forum by Nabble | Edit this page |