Page 1 of 1
Article 4: Optimizing Foundation Classes
Posted: Wed Sep 15, 2004 12:55 am
Discusssion thread for this specific optimization article.
Posted: Fri Nov 25, 2005 4:05 pm
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) ?
Posted: 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 ?
Posted: 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 ?
Posted: 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.
Posted: Mon Nov 28, 2005 2:20 pm
Isn't it less pain to add a category ?
Posted: 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.
Posted: 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 ?
Posted: 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.