mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-05-31 17:20:57 +00:00
o use of IMPs for speed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@19955 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8f4fe72e92
commit
b8fe598297
2 changed files with 58 additions and 10 deletions
|
@ -41,7 +41,9 @@
|
||||||
NSStringEncoding _contentEncoding;
|
NSStringEncoding _contentEncoding;
|
||||||
NSDictionary* _userInfo;
|
NSDictionary* _userInfo;
|
||||||
NSMutableString* _contentString;
|
NSMutableString* _contentString;
|
||||||
|
IMP _contentStringASImp;
|
||||||
NSMutableData* _contentData;
|
NSMutableData* _contentData;
|
||||||
|
IMP _contentDataADImp;
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
NSMutableArray* _cachesStack; // Cache Stacks
|
NSMutableArray* _cachesStack; // Cache Stacks
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,6 +38,9 @@ RCS_ID("$Id$")
|
||||||
static NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
|
static NSStringEncoding globalDefaultEncoding=NSISOLatin1StringEncoding;
|
||||||
static NSString* globalDefaultURLEncoding=nil;
|
static NSString* globalDefaultURLEncoding=nil;
|
||||||
|
|
||||||
|
static SEL appendStringSel = NULL;
|
||||||
|
static SEL appendDataSel = NULL;
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
|
|
||||||
|
@ -50,9 +53,28 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define assertContentStringASImp(); \
|
||||||
|
{ if (!_contentStringASImp) { \
|
||||||
|
_contentStringASImp=[_contentString \
|
||||||
|
methodForSelector:appendStringSel]; }; };
|
||||||
|
|
||||||
|
#define assertContentDataADImp(); \
|
||||||
|
{ if (!_contentDataADImp) { \
|
||||||
|
_contentDataADImp=[_contentData \
|
||||||
|
methodForSelector:appendDataSel]; }; };
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
@implementation GSWMessage
|
@implementation GSWMessage
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
if (self == [GSWMessage class])
|
||||||
|
{
|
||||||
|
appendStringSel = @selector(appendString:);
|
||||||
|
appendDataSel = @selector(appendData:);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// init
|
// init
|
||||||
|
|
||||||
|
@ -111,9 +133,11 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
|
|
||||||
DESTROY(clone->_contentString);
|
DESTROY(clone->_contentString);
|
||||||
clone->_contentString=[_contentString mutableCopyWithZone:zone];
|
clone->_contentString=[_contentString mutableCopyWithZone:zone];
|
||||||
|
clone->_contentStringASImp=NULL;
|
||||||
|
|
||||||
DESTROY(clone->_contentData);
|
DESTROY(clone->_contentData);
|
||||||
clone->_contentData=[_contentData mutableCopyWithZone:zone];
|
clone->_contentData=[_contentData mutableCopyWithZone:zone];
|
||||||
|
clone->_contentDataADImp=NULL;
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
DESTROY(clone->_cachesStack);
|
DESTROY(clone->_cachesStack);
|
||||||
|
@ -337,10 +361,16 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
-(void)_initContentData
|
-(void)_initContentData
|
||||||
{
|
{
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
|
|
||||||
DESTROY(_contentString);
|
DESTROY(_contentString);
|
||||||
DESTROY(_contentData);
|
DESTROY(_contentData);
|
||||||
|
|
||||||
_contentString=[NSMutableString new];
|
_contentString=[NSMutableString new];
|
||||||
|
_contentStringASImp=NULL;
|
||||||
|
|
||||||
_contentData=[NSMutableData new];
|
_contentData=[NSMutableData new];
|
||||||
|
_contentDataADImp=NULL;
|
||||||
|
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -425,7 +455,8 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
tmpString=[[[NSString alloc]initWithData:contentData
|
tmpString=[[[NSString alloc]initWithData:contentData
|
||||||
encoding:[self contentEncoding]]
|
encoding:[self contentEncoding]]
|
||||||
autorelease];
|
autorelease];
|
||||||
[_contentString appendString:tmpString];
|
assertContentStringASImp();
|
||||||
|
(*_contentStringASImp)(_contentString,appendStringSel,tmpString);
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
if (_cachesStack)
|
if (_cachesStack)
|
||||||
|
@ -436,11 +467,13 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
{
|
{
|
||||||
if ([_contentData length]>0)
|
if ([_contentData length]>0)
|
||||||
{
|
{
|
||||||
[_contentData appendData:contentData];
|
assertContentDataADImp();
|
||||||
|
(*_contentDataADImp)(_contentData,appendDataSel,contentData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_contentData = (NSMutableData*)[contentData mutableCopy];
|
_contentData = (NSMutableData*)[contentData mutableCopy];
|
||||||
|
_contentDataADImp = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
|
@ -456,7 +489,9 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
-(void)_appendContentAsciiString:(NSString*)aString
|
-(void)_appendContentAsciiString:(NSString*)aString
|
||||||
{
|
{
|
||||||
NSString* string=nil;
|
NSString* string=nil;
|
||||||
|
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
|
|
||||||
NSAssert2([_contentData length]==0,
|
NSAssert2([_contentData length]==0,
|
||||||
@"Try to append string but content is data. \nString: '%@'\nData: '%@'",
|
@"Try to append string but content is data. \nString: '%@'\nData: '%@'",
|
||||||
string,
|
string,
|
||||||
|
@ -468,12 +503,14 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
string=[NSString stringWithObject:aString];
|
string=[NSString stringWithObject:aString];
|
||||||
|
|
||||||
NSDebugMLLog(@"low",@"string:%@",string);
|
NSDebugMLLog(@"low",@"string:%@",string);
|
||||||
[_contentString appendString:string];
|
assertContentStringASImp();
|
||||||
|
(*_contentStringASImp)(_contentString,appendStringSel,string);
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
if (_cachesStack)
|
if (_cachesStack)
|
||||||
[self _cacheAppendString:string];
|
[self _cacheAppendString:string];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOGObjectFnStop();
|
LOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -483,7 +520,9 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
-(void)_appendContentCharacter:(char)aChar
|
-(void)_appendContentCharacter:(char)aChar
|
||||||
{
|
{
|
||||||
NSString* string=nil;
|
NSString* string=nil;
|
||||||
|
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
|
|
||||||
NSDebugMLLog(@"low",@"aChar:%c",aChar);
|
NSDebugMLLog(@"low",@"aChar:%c",aChar);
|
||||||
NSAssert2([_contentData length]==0,
|
NSAssert2([_contentData length]==0,
|
||||||
@"Try to append string but content is data. \naChar: '%c'\nData: '%@'",
|
@"Try to append string but content is data. \naChar: '%c'\nData: '%@'",
|
||||||
|
@ -492,9 +531,11 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
encoding:[self contentEncoding]]
|
encoding:[self contentEncoding]]
|
||||||
autorelease]);
|
autorelease]);
|
||||||
|
|
||||||
string=[NSString stringWithFormat:@"%c",aChar];
|
string=[NSString stringWithCString:&aChar
|
||||||
|
length:1];
|
||||||
|
|
||||||
[_contentString appendString:string];
|
assertContentStringASImp();
|
||||||
|
(*_contentStringASImp)(_contentString,appendStringSel,string);
|
||||||
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
if (_cachesStack)
|
if (_cachesStack)
|
||||||
|
@ -508,6 +549,7 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
-(void)appendContentString:(NSString*)string
|
-(void)appendContentString:(NSString*)string
|
||||||
{
|
{
|
||||||
LOGObjectFnStart();
|
LOGObjectFnStart();
|
||||||
|
|
||||||
NSDebugMLLog(@"low",@"string:%@",string);
|
NSDebugMLLog(@"low",@"string:%@",string);
|
||||||
NSAssert2([_contentData length]==0,
|
NSAssert2([_contentData length]==0,
|
||||||
@"Try to append string but content is data. \n"
|
@"Try to append string but content is data. \n"
|
||||||
|
@ -516,10 +558,10 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
[[[NSString alloc]initWithData:_contentData
|
[[[NSString alloc]initWithData:_contentData
|
||||||
encoding:[self contentEncoding]]
|
encoding:[self contentEncoding]]
|
||||||
autorelease]);
|
autorelease]);
|
||||||
if (string)
|
|
||||||
{
|
assertContentStringASImp();
|
||||||
[_contentString appendString:string];
|
(*_contentStringASImp)(_contentString,appendStringSel,string);
|
||||||
}
|
|
||||||
#ifndef NO_GNUSTEP
|
#ifndef NO_GNUSTEP
|
||||||
if (_cachesStack)
|
if (_cachesStack)
|
||||||
[self _cacheAppendString:string];
|
[self _cacheAppendString:string];
|
||||||
|
@ -652,7 +694,11 @@ static NSString* globalDefaultURLEncoding=nil;
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (GSDebugSet(@"debugComments") == YES)
|
if (GSDebugSet(@"debugComments") == YES)
|
||||||
[self appendContentString:[NSString stringWithFormat:@"\n<!-- %@ -->\n",aString]];
|
{
|
||||||
|
[self appendContentString:@"\n<!-- "];
|
||||||
|
[self appendContentString:aString];
|
||||||
|
[self appendContentString:@" -->\n"];
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue