зеркало из https://github.com/mozilla/gecko-dev.git
Bug 250000 Remove string copying in |nsIMAPGenericParser::AdvanceTokenizerStartingPoint()|
patch by Hans-A.Engel@unibas.ch r=bienvenu sr=dmose
This commit is contained in:
Родитель
057b727d02
Коммит
a6c47ca22d
|
@ -317,34 +317,28 @@ void nsIMAPGenericParser::AdvanceToNextLine()
|
|||
HandleMemoryFailure();
|
||||
}
|
||||
|
||||
// advances |fLineOfTokens| by |bytesToAdvance| bytes
|
||||
void nsIMAPGenericParser::AdvanceTokenizerStartingPoint(int32 bytesToAdvance)
|
||||
{
|
||||
PRInt32 startingDiff = fLineOfTokens - fStartOfLineOfTokens;
|
||||
PRInt32 nextTokenOffset;
|
||||
NS_PRECONDITION(bytesToAdvance>=0, "bytesToAdvance must not be negative");
|
||||
if(!fStartOfLineOfTokens)
|
||||
return;
|
||||
|
||||
// save off offset into fStartOfLineOfTokens of fNextToken so we can set it appropriately
|
||||
// when we destroy the current line and create a new one. I'm pretty sure fNextToken must
|
||||
// point somewhere in the current line.
|
||||
nextTokenOffset = fNextToken - fStartOfLineOfTokens;
|
||||
|
||||
PR_FREEIF(fStartOfLineOfTokens);
|
||||
if (fCurrentLine)
|
||||
// In the last call to GetNextToken(), the token separator was cleared to '\0'
|
||||
// iff |fCurrentTokenPlaceHolder|. We must recover this token separator now.
|
||||
if (fCurrentTokenPlaceHolder)
|
||||
{
|
||||
fStartOfLineOfTokens = PL_strdup(fCurrentLine);
|
||||
fNextToken = fStartOfLineOfTokens + nextTokenOffset;
|
||||
int endTokenOffset = fCurrentTokenPlaceHolder - fStartOfLineOfTokens - 1;
|
||||
if (endTokenOffset >= 0)
|
||||
fStartOfLineOfTokens[endTokenOffset] = fCurrentLine[endTokenOffset];
|
||||
}
|
||||
|
||||
if (fStartOfLineOfTokens && ((int32) strlen(fStartOfLineOfTokens) >= bytesToAdvance))
|
||||
{
|
||||
fLineOfTokens = fStartOfLineOfTokens + bytesToAdvance + startingDiff;
|
||||
NS_ASSERTION(bytesToAdvance + (fLineOfTokens-fStartOfLineOfTokens) <=
|
||||
(int32)strlen(fCurrentLine), "cannot advance beyond end of fLineOfTokens");
|
||||
fLineOfTokens += bytesToAdvance;
|
||||
fCurrentTokenPlaceHolder = fLineOfTokens;
|
||||
fTokenizerAdvanced = PR_TRUE;
|
||||
}
|
||||
else
|
||||
HandleMemoryFailure();
|
||||
}
|
||||
else
|
||||
HandleMemoryFailure();
|
||||
}
|
||||
|
||||
// Lots of things in the IMAP protocol are defined as an "astring."
|
||||
// An astring is either an atom or a string.
|
||||
|
|
Загрузка…
Ссылка в новой задаче