It is currently Thu Mar 28, 2024 8:14 pm

Mulle kybernetiK Optimization

Forum for Optimizations around Cocoa and Mac OS X

Article 4: Optimizing Foundation Classes

Discussion about the <a href="http://www.mulle-kybernetik.com/artikel/Optimization">Optimizing Objective-C Article Series</a>
User avatar
 
Posts: 42
Joined: Fri Aug 06, 2004 9:20 am
Location: Bochum
Website: http://www.mulle-kybernetik.com/weblog

Article 4: Optimizing Foundation Classes

Post by Nat! » Wed Sep 15, 2004 12:55 am

Discusssion thread for this specific optimization article.

 
Posts: 4
Joined: Fri Nov 25, 2005 4:02 pm
Location: Paris

Post by PowerMike » Fri Nov 25, 2005 4:05 pm

Hi,

What may happen if I subclass the class I want to optimize (class B inherits from A) and make it poses as its mother (B poses as A) ?
Mike

User avatar
 
Posts: 42
Joined: Fri Aug 06, 2004 9:20 am
Location: Bochum
Website: http://www.mulle-kybernetik.com/weblog

Post by Nat! » Sun Nov 27, 2005 6:14 pm

PowerMike wrote:What may happen if I subclass the class I want to optimize (class B inherits from A) and make it poses as its mother (B poses as A) ?


Well it should work, shouldn't it ? Or what is it you want to know specifically ?

 
Posts: 4
Joined: Fri Nov 25, 2005 4:02 pm
Location: Paris

Post by PowerMike » Mon Nov 28, 2005 11:40 am

OK, I thought of all this during the week end and I realized I had misunderstood the article.
In fact I was wondering to which extent it is profitable to write a subclass to optimize the foundation class and make it pose as the based class. As you noted subclassing NSString is maybe too hard a work if you had to rewrite any basic method. What are the hints indicating what is really worth doing ?
Mike

User avatar
 
Posts: 42
Joined: Fri Aug 06, 2004 9:20 am
Location: Bochum
Website: http://www.mulle-kybernetik.com/weblog

Post by Nat! » Mon Nov 28, 2005 11:51 am

Well the hints would be based on what part of NSStrings performance troubles you. As you know NSString is a class cluster and I think it's a pretty big code base. So it its not very complicated to create a subclass of NSString that does some operations very well - like I wrote in the article -, but it is fairly involved to write an NSString replacement, that does everything well.

 
Posts: 4
Joined: Fri Nov 25, 2005 4:02 pm
Location: Paris

Post by PowerMike » Mon Nov 28, 2005 2:20 pm

Isn't it less pain to add a category ?
Mike

User avatar
 
Posts: 42
Joined: Fri Aug 06, 2004 9:20 am
Location: Bochum
Website: http://www.mulle-kybernetik.com/weblog

Post by Nat! » Mon Nov 28, 2005 2:48 pm

PowerMike wrote:Isn't it less pain to add a category ?


If you want to augment the class cluster with some functionality, it's a good idea, though probably not very fast.

As for optimizing, NSString is a class cluster, you'd first have to pinpoint the exact class, you'd want to override (and then it would only work for that class). Then you'd have to know the internal makeup of that class - which you don't know officially - and write specific code for that. That makes your code very, very brittle. I wouldn't do that.

 
Posts: 4
Joined: Fri Nov 25, 2005 4:02 pm
Location: Paris

Post by PowerMike » Mon Nov 28, 2005 5:16 pm

Well, until today I optmized my code mostly by avoiding the use of auto-release objects. So I'm not really used to any deeper level.

What I think is astonished is that Objective-C can really be improved by optimizing the foundation class and the compiler. Have you noticed any change in the good way in recent release of Mac OS X ?
Mike

 
Posts: 10
Joined: Sat Nov 01, 2003 12:40 am

Post by admin » Mon Nov 28, 2005 5:55 pm

Your last post has been deleted. Please read the posting guide lines before posting.

Here is a direct link http://www.mulle-kybernetik.com/forum/Optimization/phpBB2/viewtopic.php?t=2 to the guide lines.


Return to “Article Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest