mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-09 08:28:45 +00:00
Fixed: Use new fast msgSend function for some foundation classes
This commit is contained in:
1 parent
0f5b36e9c5
commit
0efb7e67c9
7 files changed
+37
-29
No files matched your search
@@ -530,7 +530,7 @@ var sortArrayUsingJSDescriptors = function(a, d)
|
||||
if (value1 === nil || value1 === cpNull)
|
||||
o = value2 === nil || value2 === cpNull ? CPOrderedSame : CPOrderedAscending;
|
||||
else
|
||||
o = value2 === nil || value2 === cpNull ? CPOrderedDescending : objj_msgSend(value1, dd.s, value2);
|
||||
o = value2 === nil || value2 === cpNull ? CPOrderedDescending : value1.isa.objj_msgSend1(value1, dd.s, value2);
|
||||
|
||||
if (o && !dd.a)
|
||||
o = -o;
|
||||
|
||||
@@ -608,9 +608,11 @@ var concat = Array.prototype.concat,
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
else {
|
||||
var anIsa = self.isa;
|
||||
for (; index < count; ++index)
|
||||
objj_msgSend([self objectAtIndex:index], aSelector);
|
||||
anIsa.objj_msgSend0([self objectAtIndex:index], aSelector);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsUsingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
|
||||
@@ -748,7 +750,7 @@ var concat = Array.prototype.concat,
|
||||
// passed in is an array, we end up with its contents added instead of itself.
|
||||
push.call(argumentArray, anObject);
|
||||
|
||||
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
|
||||
return [[self class] arrayWithArray:argumentArray];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -763,7 +765,7 @@ var concat = Array.prototype.concat,
|
||||
var anArray = anArray.isa === _CPJavaScriptArray ? anArray : [anArray _javaScriptArrayCopy],
|
||||
argumentArray = concat.call([self _javaScriptArrayCopy], anArray);
|
||||
|
||||
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
|
||||
return [[self class] arrayWithArray:argumentArray];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -801,7 +803,7 @@ var concat = Array.prototype.concat,
|
||||
for (; index < count; ++index)
|
||||
push.call(argumentArray, [self objectAtIndex:index]);
|
||||
|
||||
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
|
||||
return [[self class] arrayWithArray:argumentArray];
|
||||
}
|
||||
|
||||
// Sorting arrays
|
||||
|
||||
@@ -196,8 +196,10 @@ var concat = Array.prototype.concat,
|
||||
}
|
||||
|
||||
else
|
||||
for (; index < count; ++index)
|
||||
objj_msgSend(self[index], aSelector);
|
||||
for (; index < count; ++index) {
|
||||
var receiver = self[index];
|
||||
receiver == nil ? nil : receiver.isa.objj_msgSend0(receiver, aSelector);
|
||||
}
|
||||
}
|
||||
|
||||
- (CPArray)arrayByAddingObject:(id)anObject
|
||||
|
||||
@@ -108,7 +108,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
switch (accessor[0])
|
||||
{
|
||||
case 0:
|
||||
return objj_msgSend(self, accessor[1]);
|
||||
return self.isa.objj_msgSend0(self, accessor[1]);
|
||||
|
||||
case 1:
|
||||
// FIXME: We shouldn't be creating a new one every time.
|
||||
@@ -226,7 +226,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
|
||||
switch (modifier[0])
|
||||
{
|
||||
case 0: return objj_msgSend(self, modifier[1], aValue);
|
||||
case 0: return self.isa.objj_msgSend1(self, modifier[1], aValue);
|
||||
|
||||
case 1: if ([theClass accessInstanceVariablesDirectly])
|
||||
{
|
||||
@@ -341,21 +341,21 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
|
||||
- (CPUInteger)count
|
||||
{
|
||||
return objj_msgSend(_target, _countOfSelector);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _countOfSelector);
|
||||
}
|
||||
|
||||
- (id)objectAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
if (_objectInAtIndexSelector)
|
||||
return objj_msgSend(_target, _objectInAtIndexSelector, anIndex);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _objectInAtIndexSelector, anIndex);
|
||||
|
||||
return objj_msgSend(_target, _atIndexesSelector, [CPIndexSet indexSetWithIndex:anIndex])[0];
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _atIndexesSelector, [CPIndexSet indexSetWithIndex:anIndex])[0];
|
||||
}
|
||||
|
||||
- (CPArray)objectsAtIndexes:(CPIndexSet)indexes
|
||||
{
|
||||
if (_atIndexesSelector)
|
||||
return objj_msgSend(_target, _atIndexesSelector, indexes);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _atIndexesSelector, indexes);
|
||||
|
||||
return [super objectsAtIndexes:indexes];
|
||||
}
|
||||
@@ -408,17 +408,17 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
|
||||
- (CPUInteger)count
|
||||
{
|
||||
return objj_msgSend(_target, _countOfSelector);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _countOfSelector);
|
||||
}
|
||||
|
||||
- (CPEnumerator)objectEnumerator
|
||||
{
|
||||
return objj_msgSend(_target, _enumeratorOfSelector);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _enumeratorOfSelector);
|
||||
}
|
||||
|
||||
- (id)member:(id)anObject
|
||||
{
|
||||
return objj_msgSend(_target, _memberOfSelector, anObject);
|
||||
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _memberOfSelector, anObject);
|
||||
}
|
||||
|
||||
- (Class)classForCoder
|
||||
|
||||
@@ -364,7 +364,7 @@ CPLog(@"Got some class: %@", inst);
|
||||
*/
|
||||
- (id)performSelector:(SEL)aSelector
|
||||
{
|
||||
return objj_msgSend(self, aSelector);
|
||||
return self.isa.objj_msgSend0(self, aSelector);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -375,7 +375,7 @@ CPLog(@"Got some class: %@", inst);
|
||||
*/
|
||||
- (id)performSelector:(SEL)aSelector withObject:(id)anObject
|
||||
{
|
||||
return objj_msgSend(self, aSelector, anObject);
|
||||
return self.isa.objj_msgSend1(self, aSelector, anObject);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -387,7 +387,7 @@ CPLog(@"Got some class: %@", inst);
|
||||
*/
|
||||
- (id)performSelector:(SEL)aSelector withObject:(id)anObject withObject:(id)anotherObject
|
||||
{
|
||||
return objj_msgSend(self, aSelector, anObject, anotherObject);
|
||||
return self.isa.objj_msgSend2(self, aSelector, anObject, anotherObject);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -106,17 +106,17 @@
|
||||
|
||||
- (id)performSelector:(SEL)aSelector
|
||||
{
|
||||
return objj_msgSend(self, aSelector);
|
||||
return self.isa.objj_msgSend0(self, aSelector);
|
||||
}
|
||||
|
||||
- (id)performSelector:(SEL)aSelector withObject:(id)anObject
|
||||
{
|
||||
return objj_msgSend(self, aSelector, anObject);
|
||||
return self.isa.objj_msgSend1(self, aSelector, anObject);
|
||||
}
|
||||
|
||||
- (id)performSelector:(SEL)aSelector withObject:(id)anObject withObject:(id)anotherObject
|
||||
{
|
||||
return objj_msgSend(self, aSelector, anObject, anotherObject);
|
||||
return self.isa.objj_msgSend2(self, aSelector, anObject, anotherObject);
|
||||
}
|
||||
|
||||
- (BOOL)isProxy
|
||||
|
||||
+10
-6
@@ -466,7 +466,7 @@ var _class_initialize = function(/*Class*/ aClass)
|
||||
meta.objj_msgSend2 = objj_msgSendFast2;
|
||||
meta.objj_msgSend3 = objj_msgSendFast3;
|
||||
|
||||
objj_msgSend(aClass, "initialize");
|
||||
meta.objj_msgSend0(aClass, "initialize");
|
||||
|
||||
CHANGEINFO(meta, CLS_INITIALIZED, CLS_INITIALIZING);
|
||||
}
|
||||
@@ -505,16 +505,20 @@ var _objj_forward = function(self, _cmd)
|
||||
|
||||
if (invocationClass)
|
||||
{
|
||||
var invocation = objj_msgSend(invocationClass, SEL_invocationWithMethodSignature_, signature),
|
||||
var invocation = invocationClass.isa.objj_msgSend1(invocationClass, SEL_invocationWithMethodSignature_, signature),
|
||||
index = 0,
|
||||
count = arguments.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
objj_msgSend(invocation, SEL_setArgument_atIndex_, arguments[index], index);
|
||||
if (invocation != null) {
|
||||
var invocationIsa = invocation.isa;
|
||||
|
||||
for (; index < count; ++index)
|
||||
invocationIsa.objj_msgSend2(invocation, SEL_setArgument_atIndex_, arguments[index], index);
|
||||
}
|
||||
|
||||
forwardInvocationImplementation.method_imp.call(this, self, SEL_forwardInvocation_, invocation);
|
||||
|
||||
return objj_msgSend(invocation, SEL_returnValue);
|
||||
return invocation == null ? null : invocationIsa.objj_msgSend0(invocation, SEL_returnValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1000,7 +1004,7 @@ objj_class.prototype.toString = objj_object.prototype.toString = function()
|
||||
var isa = this.isa;
|
||||
|
||||
if (class_getInstanceMethod(isa, SEL_description))
|
||||
return objj_msgSend(this, SEL_description);
|
||||
return isa.objj_msgSend0(this, SEL_description);
|
||||
|
||||
if (class_isMetaClass(isa))
|
||||
return this.name;
|
||||
|
||||
Reference in new issue
Block a user