gnustep-dev
[Top][All Lists]
Advanced

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

Re: Question on file GSString.m


From: Fred Kiefer
Subject: Re: Question on file GSString.m
Date: Sun, 14 Aug 2011 23:09:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11

On 14.08.2011 22:57, Richard Frith-Macdonald wrote:

On 14 Aug 2011, at 21:20, Fred Kiefer wrote:

I just noticed that we have lots of reimplementation of NSString
methods in the sub classes in GSString.m. Some of these are
actually needed like implementing
-initWithBytesNoCopy:length:encoding:freeWhenDone:, many others
look plain wrong. Why would we duplicate code here, in some cases
even in a worse form? After the current code freeze on base, could
somebody please go through this file and clean out the duplicated
methods?

Subclasses are *supposed* to reimplement the methods of a class
cluster ... 1. the primitive methods have to be implemented for the
classes to function at all 2. many/most other methods need to be
implemented in terms of the concrete ivars actually used ... so we
get decent performance.

There shouldn't be any real duplication of code, but there should be
a *lot* of methods re-implemented ...  to access the 8 or 16 bit
character data within the strings directly.  These should *not* be
'cleaned out' since they are essential for decent performance.

There seems to be a disagreement here, so lets look at one example.
GSPlaceholderString has this method:

- (id) initWithCharacters: (const unichar*)chars
                   length: (NSUInteger)length
{
  return [self initWithBytes: (const void*)chars
                      length: length * sizeof(unichar)
                    encoding: NSUnicodeStringEncoding];
}

NSString has the following corresponding method:

- (id) initWithCharacters: (const unichar*)chars
                   length: (NSUInteger)length
{
  return [self initWithBytes: chars
                      length: length * sizeof(unichar)
                    encoding: NSUnicodeStringEncoding];
}

I don't quite see how the only difference (the type cast) is "essential for decent performance".

I do understand that what you wrote is the basic idea of what should go into this file. I just have the impression that at the moment this isn't what is in the file and I would like to see that corrected. I also know that this has to be done very carefully as just using the implementation in NSString might result in circular call sequences or very bad performance.



reply via email to

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