mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 01:21:08 +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
93d9a62c3e
commit
7c65fc9555
2 changed files with 19 additions and 4 deletions
|
@ -244,6 +244,14 @@ extern "C" {
|
||||||
- (BOOL) isInHeaders;
|
- (BOOL) isInHeaders;
|
||||||
- (GSMimeDocument*) mimeDocument;
|
- (GSMimeDocument*) mimeDocument;
|
||||||
- (BOOL) parse: (NSData*)d;
|
- (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) parseHeaders: (NSData*)d remaining: (NSData**)body;
|
||||||
- (BOOL) parseHeader: (NSString*)aHeader;
|
- (BOOL) parseHeader: (NSString*)aHeader;
|
||||||
- (BOOL) scanHeaderBody: (NSScanner*)scanner into: (GSMimeHeader*)info;
|
- (BOOL) scanHeaderBody: (NSScanner*)scanner into: (GSMimeHeader*)info;
|
||||||
|
|
|
@ -1357,13 +1357,11 @@ wordData(NSString *word)
|
||||||
}
|
}
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
{
|
{
|
||||||
NSData *dummy = nil;
|
|
||||||
|
|
||||||
/* Add an empty line to the end of the current headers to force
|
/* Add an empty line to the end of the current headers to force
|
||||||
* completion of header parsing.
|
* completion of header parsing.
|
||||||
*/
|
*/
|
||||||
[self parseHeaders: [NSData dataWithBytes: "\r\n\r\n" length: 4]
|
[self parseHeaders: [NSData dataWithBytes: "\r\n\r\n" length: 4]
|
||||||
remaining: &dummy];
|
remaining: 0];
|
||||||
flags.wantEndOfLine = 0;
|
flags.wantEndOfLine = 0;
|
||||||
flags.inBody = 0;
|
flags.inBody = 0;
|
||||||
flags.complete = 1; /* Finished parsing */
|
flags.complete = 1; /* Finished parsing */
|
||||||
|
@ -1386,7 +1384,16 @@ wordData(NSString *word)
|
||||||
[data appendBytes: [d bytes] length: i];
|
[data appendBytes: [d bytes] length: i];
|
||||||
bytes = (unsigned char*)[data bytes];
|
bytes = (unsigned char*)[data bytes];
|
||||||
dataEnd = [data length];
|
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)
|
if (body != 0)
|
||||||
{
|
{
|
||||||
*body = d;
|
*body = d;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue