The Trunk: Environments-nice.65.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Environments-nice.65.mcz

commits-2
Nicolas Cellier uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-nice.65.mcz

==================== Summary ====================

Name: Environments-nice.65
Author: nice
Time: 27 October 2016, 10:08:03.941801 pm
UUID: 4a821e74-4b6d-4077-9d3b-86d4ce6ed64d
Ancestors: Environments-nice.64

Fix two copy/paste bugs: don't notify observers that a binding is added when it's removed.

If a binding is already imported, then avoid an unecessary removeKey: / add:
Note that this is a poor workaround to mitigate a bit the following overhead: when a (newEnvironment import: Smalltalk globals), every other environment that already import Smalltalk globals will get asked to showBinding: for each Smalltalk globals declaration.
We'd better fix import: to be more chirurgical.

=============== Diff against Environments-nice.64 ===============

Item was changed:
  ----- Method: Environment>>exportAddingPrefix: (in category 'configuring') -----
  exportAddingPrefix: aString
  | policy |
  policy := BindingPolicy
  environment: self
  policy: (AddPrefixNamePolicy prefix: aString)
  addSelector: #notifyObserversOfBindingAdded:
+ removeSelector: #notifyObserversOfBindingRemoved:.
- removeSelector: #notifyObserversOfBindingAdded:.
  policies := policies copyWith: policy!

Item was changed:
  ----- Method: Environment>>exportRemovingPrefix: (in category 'configuring') -----
  exportRemovingPrefix: aString
  | policy |
  policy := BindingPolicy
  environment: self
  policy: (RemovePrefixNamePolicy prefix: aString)
  addSelector: #notifyObserversOfBindingAdded:
+ removeSelector: #notifyObserversOfBindingRemoved:.
- removeSelector: #notifyObserversOfBindingAdded:.
  policies := policies copyWith: policy!

Item was changed:
  ----- Method: Environment>>showBinding: (in category 'binding') -----
  showBinding: aBinding
  | binding |
  binding := undeclared associationAt: aBinding key ifAbsent: [nil].
  binding ifNotNil:
  [undeclared removeKey: binding key.
  binding becomeForward: aBinding].
 
  binding := bindings associationAt: aBinding key ifAbsent: [nil].
  binding ifNotNil:
+ [binding == aBinding ifTrue: [^self].
+ bindings removeKey: binding key].
- [bindings removeKey: binding key].
 
  bindings add: aBinding.!