瀏覽代碼

Take advantage of inlining in few pieces in core.

Herbert Vojčík 7 年之前
父節點
當前提交
99468eac92
共有 4 個文件被更改,包括 37 次插入46 次删除
  1. 18 25
      src/Kernel-Collections.js
  2. 3 3
      src/Kernel-Collections.st
  3. 12 14
      src/Kernel-Objects.js
  4. 4 4
      src/Kernel-Objects.st

+ 18 - 25
src/Kernel-Collections.js

@@ -1027,20 +1027,21 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 var $1;
 var $1;
 $1=self._isEmpty();
 $1=self._isEmpty();
-return $recv($1)._ifTrue_ifFalse_(aBlock,(function(){
+if($core.assert($1)){
+return $recv(aBlock)._value();
+} else {
 return self;
 return self;
-
-}));
+};
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock},$globals.Collection)});
 }, function($ctx1) {$ctx1.fill(self,"ifEmpty:",{aBlock:aBlock},$globals.Collection)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock"],
 args: ["aBlock"],
-source: "ifEmpty: aBlock\x0a\x09\x22Evaluate the given block with the receiver as argument, answering its value if the receiver is empty, otherwise answer the receiver. \x0a\x09Note that the fact that this method returns its argument in case the receiver is not empty allows one to write expressions like the following ones: \x0a\x09\x09self classifyMethodAs:\x0a\x09\x09\x09(myProtocol ifEmpty: ['As yet unclassified'])\x22\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ self ]",
+source: "ifEmpty: aBlock\x0a\x09\x22Evaluate the given block with the receiver as argument, answering its value if the receiver is empty, otherwise answer the receiver. \x0a\x09Note that the fact that this method returns its argument in case the receiver is not empty allows one to write expressions like the following ones: \x0a\x09\x09self classifyMethodAs:\x0a\x09\x09\x09(myProtocol ifEmpty: ['As yet unclassified'])\x22\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: \x22aBlock\x22 [ aBlock value ]\x0a\x09\x09ifFalse: [ self ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "isEmpty"]
+messageSends: ["ifTrue:ifFalse:", "isEmpty", "value"]
 }),
 }),
 $globals.Collection);
 $globals.Collection);
 
 
@@ -1055,25 +1056,21 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 var $1;
 var $1;
 $1=self._isEmpty();
 $1=self._isEmpty();
-return $recv($1)._ifTrue_ifFalse_(aBlock,(function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
+if($core.assert($1)){
+return $recv(aBlock)._value();
+} else {
 return $recv(anotherBlock)._value_(self);
 return $recv(anotherBlock)._value_(self);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
-//>>excludeEnd("ctx");
-}));
+};
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"ifEmpty:ifNotEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},$globals.Collection)});
 }, function($ctx1) {$ctx1.fill(self,"ifEmpty:ifNotEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},$globals.Collection)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock", "anotherBlock"],
 args: ["aBlock", "anotherBlock"],
-source: "ifEmpty: aBlock ifNotEmpty: anotherBlock\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ anotherBlock value: self ]",
+source: "ifEmpty: aBlock ifNotEmpty: anotherBlock\x0a\x09^ self isEmpty\x0a\x09\x09ifTrue: \x22aBlock\x22 [ aBlock value ]\x0a\x09\x09ifFalse: [ anotherBlock value: self ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "isEmpty", "value:"]
+messageSends: ["ifTrue:ifFalse:", "isEmpty", "value", "value:"]
 }),
 }),
 $globals.Collection);
 $globals.Collection);
 
 
@@ -1117,25 +1114,21 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 var $1;
 var $1;
 $1=self._notEmpty();
 $1=self._notEmpty();
-return $recv($1)._ifTrue_ifFalse_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
+if($core.assert($1)){
 return $recv(aBlock)._value_(self);
 return $recv(aBlock)._value_(self);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
-//>>excludeEnd("ctx");
-}),anotherBlock);
+} else {
+return $recv(anotherBlock)._value();
+};
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:ifEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},$globals.Collection)});
 }, function($ctx1) {$ctx1.fill(self,"ifNotEmpty:ifEmpty:",{aBlock:aBlock,anotherBlock:anotherBlock},$globals.Collection)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock", "anotherBlock"],
 args: ["aBlock", "anotherBlock"],
-source: "ifNotEmpty: aBlock ifEmpty: anotherBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: [ aBlock value: self ]\x0a\x09\x09ifFalse: anotherBlock",
+source: "ifNotEmpty: aBlock ifEmpty: anotherBlock\x0a\x09^ self notEmpty\x0a\x09\x09ifTrue: [ aBlock value: self ]\x0a\x09\x09ifFalse: \x22anotherBlock\x22 [ anotherBlock value ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:"]
+messageSends: ["ifTrue:ifFalse:", "notEmpty", "value:", "value"]
 }),
 }),
 $globals.Collection);
 $globals.Collection);
 
 

+ 3 - 3
src/Kernel-Collections.st

@@ -375,13 +375,13 @@ ifEmpty: aBlock
 		self classifyMethodAs:
 		self classifyMethodAs:
 			(myProtocol ifEmpty: ['As yet unclassified'])"
 			(myProtocol ifEmpty: ['As yet unclassified'])"
 	^ self isEmpty
 	^ self isEmpty
-		ifTrue: aBlock
+		ifTrue: "aBlock" [ aBlock value ]
 		ifFalse: [ self ]
 		ifFalse: [ self ]
 !
 !
 
 
 ifEmpty: aBlock ifNotEmpty: anotherBlock
 ifEmpty: aBlock ifNotEmpty: anotherBlock
 	^ self isEmpty
 	^ self isEmpty
-		ifTrue: aBlock
+		ifTrue: "aBlock" [ aBlock value ]
 		ifFalse: [ anotherBlock value: self ]
 		ifFalse: [ anotherBlock value: self ]
 !
 !
 
 
@@ -394,7 +394,7 @@ ifNotEmpty: aBlock
 ifNotEmpty: aBlock ifEmpty: anotherBlock
 ifNotEmpty: aBlock ifEmpty: anotherBlock
 	^ self notEmpty
 	^ self notEmpty
 		ifTrue: [ aBlock value: self ]
 		ifTrue: [ aBlock value: self ]
-		ifFalse: anotherBlock
+		ifFalse: "anotherBlock" [ anotherBlock value ]
 !
 !
 
 
 includes: anObject
 includes: anObject

+ 12 - 14
src/Kernel-Objects.js

@@ -1765,22 +1765,21 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-var $1;
-$1=self.__eq(true);
-return $recv($1)._ifTrue_ifFalse_(aBlock,(function(){
+if($core.assert(self)){
+return $recv(aBlock)._value();
+} else {
 return false;
 return false;
-
-}));
+};
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"and:",{aBlock:aBlock},$globals.Boolean)});
 }, function($ctx1) {$ctx1.fill(self,"and:",{aBlock:aBlock},$globals.Boolean)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock"],
 args: ["aBlock"],
-source: "and: aBlock\x0a\x09^ self = true\x0a\x09\x09ifTrue: aBlock\x0a\x09\x09ifFalse: [ false ]",
+source: "and: aBlock\x0a\x09^ self\x0a\x09\x09ifTrue: \x22aBlock\x22 [ aBlock value ]\x0a\x09\x09ifFalse: [ false ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "="]
+messageSends: ["ifTrue:ifFalse:", "value"]
 }),
 }),
 $globals.Boolean);
 $globals.Boolean);
 
 
@@ -2042,22 +2041,21 @@ var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-var $1;
-$1=self.__eq(true);
-return $recv($1)._ifTrue_ifFalse_((function(){
+if($core.assert(self)){
 return true;
 return true;
-
-}),aBlock);
+} else {
+return $recv(aBlock)._value();
+};
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"or:",{aBlock:aBlock},$globals.Boolean)});
 }, function($ctx1) {$ctx1.fill(self,"or:",{aBlock:aBlock},$globals.Boolean)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aBlock"],
 args: ["aBlock"],
-source: "or: aBlock\x0a\x09^ self = true\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: aBlock",
+source: "or: aBlock\x0a\x09^ self\x0a\x09\x09ifTrue: [ true ]\x0a\x09\x09ifFalse: \x22aBlock\x22 [ aBlock value ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:ifFalse:", "="]
+messageSends: ["ifTrue:ifFalse:", "value"]
 }),
 }),
 $globals.Boolean);
 $globals.Boolean);
 
 

+ 4 - 4
src/Kernel-Objects.st

@@ -451,8 +451,8 @@ I am directly mapped to JavaScript Boolean. The `true` and `false` objects are t
 !
 !
 
 
 and: aBlock
 and: aBlock
-	^ self = true
-		ifTrue: aBlock
+	^ self
+		ifTrue: "aBlock" [ aBlock value ]
 		ifFalse: [ false ]
 		ifFalse: [ false ]
 !
 !
 
 
@@ -487,9 +487,9 @@ not
 !
 !
 
 
 or: aBlock
 or: aBlock
-	^ self = true
+	^ self
 		ifTrue: [ true ]
 		ifTrue: [ true ]
-		ifFalse: aBlock
+		ifFalse: "aBlock" [ aBlock value ]
 !
 !
 
 
 | aBoolean
 | aBoolean