Levente Uzonyi uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-ul.748.mcz ==================== Summary ==================== Name: System-ul.748 Author: ul Time: 1 July 2015, 1:17:39.216 pm UUID: 7e127e9c-33da-4199-b81f-324808eebfae Ancestors: System-eem.747 - Iterate over pragmas once per method instead of once per pragma in Preferences class>>prefEvent:. - There's no need to copy preferencesDictionary in Preferences class>>storePreferencesIn:, because it's a read-only data structure. - Ensure the durability of the changes of preferencesDictionary in Preferences class>>atomicUpdatePreferences: by checking for changes before overwriting it. =============== Diff against System-eem.747 =============== Item was changed: ----- Method: Preferences class>>atomicUpdatePreferences: (in category 'accessing') ----- + atomicUpdatePreferences: aBlock - atomicUpdatePreferences: aBlock "Evaluate aBlock with a copy of the preferences dictionary and + then assign (assignment is atomic) the copy to the dictionary." + + [ + | originalPreferences copyOfPreferences | + originalPreferences := preferencesDictionary. + copyOfPreferences := preferencesDictionary + ifNil: [ IdentityDictionary new ] + ifNotNil: [ :dictionary | dictionary copy ]. + aBlock value: copyOfPreferences. + originalPreferences == preferencesDictionary ifTrue: [ + preferencesDictionary := copyOfPreferences. + ^self ] ] repeat! - then assign (assignment is atomic) the copy to the dictionary." - | copyOfPreferences | - copyOfPreferences := preferencesDictionary - ifNil: [IdentityDictionary new] - ifNotNil: [:dict| dict copy]. - aBlock value: copyOfPreferences. - preferencesDictionary := copyOfPreferences! Item was changed: ----- Method: Preferences class>>prefEvent: (in category 'dynamic preferences') ----- prefEvent: anEvent "Check if this system event defines or removes a preference. TODO: Queue the event and handle in background process. There is zero reason to be so eager here." + + | aClass aSelector | - | aClass aSelector method | anEvent itemKind = SystemChangeNotifier classKind ifTrue: [^anEvent isRemoved ifTrue: [self removePreferencesFor: anEvent item]]. (anEvent itemKind = SystemChangeNotifier methodKind and: [(aClass := anEvent itemClass) isMeta]) ifFalse: "ignore instance methods" [^self]. aClass := aClass theNonMetaClass. aSelector := anEvent itemSelector. anEvent isRemoved ifTrue: [self atomicUpdatePreferences: [ :copyOfDictionaryOfPreferences | copyOfDictionaryOfPreferences removeKey: (aClass name,'>>', aSelector) asSymbol ifAbsent: []]] ifFalse: [(anEvent isAdded or: [anEvent isModified]) ifTrue: + [self respondToPreferencePragmasInMethod: anEvent item class: aClass]]! - [method := anEvent item. - method pragmas do: - [:pragma| - self respondToPreferencePragmasInMethod: method class: aClass]]]! Item was changed: ----- Method: Preferences class>>storePreferencesIn: (in category 'personalization') ----- + storePreferencesIn: aFileName + + | stream | - storePreferencesIn: aFileName - | stream prefsSnapshot | #(Prevailing PersonalPreferences) do: [:ea | Parameters removeKey: ea ifAbsent: []]. stream := ReferenceStream fileNamed: aFileName. stream nextPut: Parameters. + preferencesDictionary keysAndValuesDo: [:key :pref | preferencesDictionary at: key put: pref asPreference]. + stream nextPut: preferencesDictionary. - prefsSnapshot := preferencesDictionary copy. - prefsSnapshot keysAndValuesDo: [:key :pref | prefsSnapshot at: key put: pref asPreference]. - stream nextPut: prefsSnapshot. stream nextPut: (Smalltalk isMorphic ifTrue:[World fillStyle] ifFalse:[DesktopColor]). stream close! |
Free forum by Nabble | Edit this page |