Browse Source

Using `prop in obj` to detect primitive element presence

Herbert Vojčík 11 years ago
parent
commit
434d4c34a2
2 changed files with 6 additions and 6 deletions
  1. 4 4
      js/Kernel-Collections.js
  2. 2 2
      st/Kernel-Collections.st

+ 4 - 4
js/Kernel-Collections.js

@@ -5388,13 +5388,13 @@ fn: function (anObject,anotherObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 
-		if (anotherObject.store[anObject]) { return false; }
+		if (anObject in anotherObject.store) { return false; }
 		self['@size']++;
 		return anotherObject.store[anObject] = true;
 	;
 return self}, function($ctx1) {$ctx1.fill(self,"add:in:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Set)})},
 args: ["anObject", "anotherObject"],
-source: "add: anObject in: anotherObject\x0a\x09<\x0a\x09\x09if (anotherObject.store[anObject]) { return false; }\x0a\x09\x09self['@size']++;\x0a\x09\x09return anotherObject.store[anObject] = true;\x0a\x09>",
+source: "add: anObject in: anotherObject\x0a\x09<\x0a\x09\x09if (anObject in anotherObject.store) { return false; }\x0a\x09\x09self['@size']++;\x0a\x09\x09return anotherObject.store[anObject] = true;\x0a\x09>",
 messageSends: [],
 referencedClasses: []
 }),
@@ -5545,10 +5545,10 @@ protocol: 'private',
 fn: function (anObject,anotherObject){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-return !!anotherObject.store[anObject];
+return anObject in anotherObject.store;
 return self}, function($ctx1) {$ctx1.fill(self,"includes:in:",{anObject:anObject,anotherObject:anotherObject},smalltalk.Set)})},
 args: ["anObject", "anotherObject"],
-source: "includes: anObject in: anotherObject\x0a\x09<return !!anotherObject.store[anObject]>",
+source: "includes: anObject in: anotherObject\x0a\x09<return anObject in anotherObject.store>",
 messageSends: [],
 referencedClasses: []
 }),

+ 2 - 2
st/Kernel-Collections.st

@@ -1849,7 +1849,7 @@ printOn: aStream
 
 add: anObject in: anotherObject
 	<
-		if (anotherObject.store[anObject]) { return false; }
+		if (anObject in anotherObject.store) { return false; }
 		self['@size']++;
 		return anotherObject.store[anObject] = true;
 	>
@@ -1871,7 +1871,7 @@ bucketOfElement: anObject
 !
 
 includes: anObject in: anotherObject
-	<return !!!!anotherObject.store[anObject]>
+	<return anObject in anotherObject.store>
 !
 
 remove: anObject in: anotherObject