mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
tweak for performance
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30673 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
aa3592307c
commit
dcf5647de3
2 changed files with 19 additions and 4 deletions
|
@ -244,6 +244,14 @@ extern "C" {
|
|||
- (BOOL) isInHeaders;
|
||||
- (GSMimeDocument*) mimeDocument;
|
||||
- (BOOL) parse: (NSData*)d;
|
||||
/** Parses headers from the supplied data returning YES if more data is
|
||||
* needed before the end of thge headers are reached.<br />
|
||||
* If body is not NULL and the end of the headers were reached leaving
|
||||
* some unused data, that remaining data is returned.<br />
|
||||
* NB. The returned data is a reference to part of the original memory
|
||||
* buffer provided in d, so you must copy it if you intend to use it after
|
||||
* modifying or deallocating the original data.
|
||||
*/
|
||||
- (BOOL) parseHeaders: (NSData*)d remaining: (NSData**)body;
|
||||
- (BOOL) parseHeader: (NSString*)aHeader;
|
||||
- (BOOL) scanHeaderBody: (NSScanner*)scanner into: (GSMimeHeader*)info;
|
||||
|
|
|
@ -1357,13 +1357,11 @@ wordData(NSString *word)
|
|||
}
|
||||
if (l == 0)
|
||||
{
|
||||
NSData *dummy = nil;
|
||||
|
||||
/* Add an empty line to the end of the current headers to force
|
||||
* completion of header parsing.
|
||||
*/
|
||||
[self parseHeaders: [NSData dataWithBytes: "\r\n\r\n" length: 4]
|
||||
remaining: &dummy];
|
||||
remaining: 0];
|
||||
flags.wantEndOfLine = 0;
|
||||
flags.inBody = 0;
|
||||
flags.complete = 1; /* Finished parsing */
|
||||
|
@ -1386,7 +1384,16 @@ wordData(NSString *word)
|
|||
[data appendBytes: [d bytes] length: i];
|
||||
bytes = (unsigned char*)[data bytes];
|
||||
dataEnd = [data length];
|
||||
d = [d subdataWithRange: NSMakeRange(i, l - i)];
|
||||
if (l > i)
|
||||
{
|
||||
d = [[[NSData alloc] initWithBytesNoCopy: (void*)([d bytes] + i)
|
||||
length: l - i
|
||||
freeWhenDone: NO] autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
d = nil;
|
||||
}
|
||||
if (body != 0)
|
||||
{
|
||||
*body = d;
|
||||
|
|
Loading…
Reference in a new issue