Speeding up ComposableModel new openWithSpec (in Pharo v3)

I need a graphical interface with 81 drawers in which the user can select one number (this is a game board).

So, I have subclassed ComposableModelwith 81 instance variables, each of which is initialized with a new instance TextInputFieldModel.

The problem is that it takes about 6 seconds to open. Why does it take so long to open 81 text boxes? Is there something I can do to expedite the discovery?

+4
source share
2 answers

Profiler . → . :

| specArray widgets view layout |
" Configure the Spec models "
specArray := OrderedCollection new: 81 * 2.
1 to: 81 do: [ : index | specArray 
    add: ('textInput' , index asString) asSymbol;
    add: #TextInputFieldModel ].
view := DynamicComposableModel new
        instantiateModels: specArray;
        extent: 300@800;
        title: 'Title'
        yourself.
" Configure the Spec layout "
widgets := specArray reject: [ : ti | ti = #TextInputFieldModel ].
layout := SpecLayout composed
        newColumn: [ : r | 
        widgets doWithIndex: [ : ti : index | r add: ti ] ];
        yourself.
" Set up the widgets "
widgets doWithIndex: [ : each : index | (view perform: each) text: index asString  ].
" Open the Window "
(view openWithSpecLayout: layout) delete.

, TextInputFieldModel → defaultEntryCompletion, ( , )

enter image description here

,

  • 3902, 3912 .
  • 3916 , 3927 .

  • 1985 , 1988 .

TextInputFieldModel → defaultEntryCompletion :

defaultEntryCompletion

    | applicants |
    applicants := (Array streamContents: [:strm | 
                    Smalltalk globals keysDo: [ : each | (each notEmpty and: [each first canBeGlobalVarInitial]) 
                        ifTrue: [ strm nextPut: each ] ] ]) sort.

    ^ EntryCompletion new
                dataSourceBlock: [:currText | applicants];
                filterBlock: [:currApplicant :currText | currText size > 3
                        and: [currApplicant asUppercase includesSubstring: currText asString asUppercase]].
+4

- . , , .

+3

Source: https://habr.com/ru/post/1569834/


All Articles