Browse Source

DirectTrapper not writing if new value not different.

Herbert Vojčík 6 years ago
parent
commit
6cc2fd6bda
2 changed files with 8 additions and 4 deletions
  1. 7 3
      src/Trapped-Backend.js
  2. 1 1
      src/Trapped-Backend.st

+ 7 - 3
src/Trapped-Backend.js

@@ -645,13 +645,17 @@ var newValue,eavModel;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
+var $1;
 eavModel=$recv(path)._asEavModel();
 newValue=$recv(aBlock)._value_($recv(eavModel)._on_($self["@payload"]));
 $recv((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
+$1=$recv($self["@payload"]).__eq_eq(newValue);
+if(!$core.assert($1)){
 return $recv(eavModel)._on_put_($self["@payload"],newValue);
+}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -661,7 +665,7 @@ return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 return $self._changed_(path);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
 //>>excludeEnd("ctx");
 }));
 return self;
@@ -671,10 +675,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["path", "aBlock"],
-source: "modify: path do: aBlock\x0a    | newValue eavModel |\x0a    eavModel := path asEavModel.\x0a    newValue := aBlock value: (eavModel on: payload).\x0a    [ eavModel on: payload put: newValue ] ensure: [ self changed: path ]",
+source: "modify: path do: aBlock\x0a    | newValue eavModel |\x0a    eavModel := path asEavModel.\x0a    newValue := aBlock value: (eavModel on: payload).\x0a    [ payload == newValue ifFalse: [ eavModel on: payload put: newValue ] ] ensure: [ self changed: path ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["asEavModel", "value:", "on:", "ensure:", "on:put:", "changed:"]
+messageSends: ["asEavModel", "value:", "on:", "ensure:", "ifFalse:", "==", "on:put:", "changed:"]
 }),
 $globals.DirectTrapper);
 

+ 1 - 1
src/Trapped-Backend.st

@@ -193,7 +193,7 @@ modify: path do: aBlock
     | newValue eavModel |
     eavModel := path asEavModel.
     newValue := aBlock value: (eavModel on: payload).
-    [ eavModel on: payload put: newValue ] ensure: [ self changed: path ]
+    [ payload == newValue ifFalse: [ eavModel on: payload put: newValue ] ] ensure: [ self changed: path ]
 !
 
 read: path do: aBlock