gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnustep-cvs] Fix NSCharacterSet caching bug


From: Richard Frith-Macdonald
Subject: Re: [Gnustep-cvs] Fix NSCharacterSet caching bug
Date: Sat, 1 Nov 2003 10:44:08 +0000


On Saturday, November 1, 2003, at 10:25 AM, David Ayers wrote:

Richard Frith-Macdonald  wrote:

*+* * Source/NSCharacterSet.m *+* ([NSCharacterSet _bitmapForSet:number:]): Restore caching while
*+* retaining the intended behavior of the previous change (is that
*+* intended behavior correct?).
*+* Perhaps should maintain a separate cache for each subclass ...
*+* or should that be the responsibility of the subclass itsself?

Actually my intent was *not* to retain a cache for subclasses (especially mutable sets). If I want mutable set, then I generally mean to alter it (like inverting itn). If the next caller get's the altered cached object, he's not getting what he asks for. We can only cache immutable versions, and then each subclass must do it's own caching. (Maybe I should have added a comment.) But I'll add an extra test.

Yet (except for the caching) I'm not sure what the real change is. Instead of:

        if ([self isSubclassOfClass: [NSCharacterSet class]])

we now have

        if (self != abstract && self != [set class])

where the [set class] is always initialized by:

        set = [NSCharacterSet characterSetWithBitmapRepresentation: data];

Yet if it's not the same class but it invokes this implementation must'n it be the a subclass?

So in that sense, your change didn't alter the behavior.

Your change turned off caching ... since the test [self isSubclassOfClass: [NSCharacterSet class]]
would always be true.

My code turns the caching back on for two cases ... where the class to which the message is
sent is either NSCharacterSet or NSBitmapCharacterSet

My comment was intended to say that, if the message is sent to the class MyCharacterSet (where MyCharacterSet is a custom subclass of NSCharacterSet (but not of NSMutableCharacterSet)), presumably we would like to cache instances of MyCharacterSet and return the cached versions rather than creating a new instance each time. Is it worth building that caching into the abstract NSCharacterSet code, or should MyCharacterSet override the methods to implement caching itsself. I think probably the latter.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]