зеркало из https://github.com/mozilla/pjs.git
fix for bug 164577 - make the nsManifestLineReader include lengths from ParseLine() so that consumers can avoid calling strlen() on them
(tiny startup perf fix for reading in xpti.dat) r=dougt, sr=darin
This commit is contained in:
Родитель
bac341b7d0
Коммит
78911bf128
|
@ -966,7 +966,8 @@ PRBool ReadSectionHeader(nsManifestLineReader& reader, const char *token)
|
|||
*p = 0;
|
||||
|
||||
char* values[1];
|
||||
if(2 != reader.ParseLine(values, 1))
|
||||
int lengths[1];
|
||||
if(2 != reader.ParseLine(values, lengths, 1))
|
||||
break;
|
||||
|
||||
// ignore the leading '['
|
||||
|
@ -1059,10 +1060,11 @@ nsComponentManagerImpl::ReadPersistentRegistry()
|
|||
if(!reader.NextLine())
|
||||
goto out;
|
||||
|
||||
char* values[6];
|
||||
char* values[6];
|
||||
int lengths[6];
|
||||
|
||||
// VersionLiteral,major,minor
|
||||
if(3 != reader.ParseLine(values, 3))
|
||||
if(3 != reader.ParseLine(values, lengths, 3))
|
||||
goto out;
|
||||
|
||||
// VersionLiteral
|
||||
|
@ -1086,7 +1088,7 @@ nsComponentManagerImpl::ReadPersistentRegistry()
|
|||
break;
|
||||
|
||||
//name,last_modification_date
|
||||
if(2 != reader.ParseLine(values, 2))
|
||||
if(2 != reader.ParseLine(values, lengths, 2))
|
||||
break;
|
||||
|
||||
PRInt64 a = nsCRT::atoll(values[1]);
|
||||
|
@ -1107,7 +1109,7 @@ nsComponentManagerImpl::ReadPersistentRegistry()
|
|||
break;
|
||||
|
||||
// cid,contract_id,type,class_name,inproc_server
|
||||
if(5 != reader.ParseLine(values, 5))
|
||||
if(5 != reader.ParseLine(values, lengths, 5))
|
||||
break;
|
||||
|
||||
nsCID aClass;
|
||||
|
@ -1148,7 +1150,7 @@ nsComponentManagerImpl::ReadPersistentRegistry()
|
|||
break;
|
||||
|
||||
//contractID,cid
|
||||
if(2 != reader.ParseLine(values, 2))
|
||||
if(2 != reader.ParseLine(values, lengths, 2))
|
||||
break;
|
||||
|
||||
nsCID aClass;
|
||||
|
@ -1185,7 +1187,7 @@ nsComponentManagerImpl::ReadPersistentRegistry()
|
|||
break;
|
||||
|
||||
//type,name,value
|
||||
if(3 != reader.ParseLine(values, 3))
|
||||
if(3 != reader.ParseLine(values, lengths, 3))
|
||||
break;
|
||||
|
||||
catman->AddCategoryEntry(values[0],
|
||||
|
|
|
@ -78,24 +78,30 @@ public:
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
int ParseLine(char** chunks, int maxChunks)
|
||||
int ParseLine(char** chunks, int* lengths, int maxChunks)
|
||||
{
|
||||
NS_ASSERTION(mCur && maxChunks && chunks, "bad call to ParseLine");
|
||||
int found = 0;
|
||||
chunks[found++] = mCur;
|
||||
|
||||
|
||||
if(found < maxChunks)
|
||||
{
|
||||
char *lastchunk = mCur;
|
||||
int *lastlength = lengths;
|
||||
for(char* cur = mCur; *cur; cur++)
|
||||
{
|
||||
if(*cur == ',')
|
||||
{
|
||||
*cur = 0;
|
||||
chunks[found++] = cur+1;
|
||||
// always fill in the previous chunk's length
|
||||
*lastlength++ = cur - lastchunk;
|
||||
chunks[found++] = lastchunk = cur+1;
|
||||
if(found == maxChunks)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// crazy pointer math - calculate the length of the final chunk
|
||||
*lastlength = (mCur + mLength) - lastchunk;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
|
|
@ -87,11 +87,11 @@ void xptiInterfaceInfo::DEBUG_ShutdownNotification()
|
|||
// static
|
||||
xptiInterfaceEntry*
|
||||
xptiInterfaceEntry::NewEntry(const char* name,
|
||||
int nameLength,
|
||||
const nsID& iid,
|
||||
const xptiTypelib& typelib,
|
||||
xptiWorkingSet* aWorkingSet)
|
||||
{
|
||||
size_t nameLength = PL_strlen(name);
|
||||
void* place = XPT_MALLOC(aWorkingSet->GetStructArena(),
|
||||
sizeof(xptiInterfaceEntry) + nameLength);
|
||||
if(!place)
|
||||
|
|
|
@ -1306,7 +1306,8 @@ xptiInterfaceInfoManager::VerifyAndAddEntryIfNew(xptiWorkingSet* aWorkingSet,
|
|||
|
||||
// Build a new xptiInterfaceEntry object and hook it up.
|
||||
|
||||
entry = xptiInterfaceEntry::NewEntry(iface->name, iface->iid,
|
||||
entry = xptiInterfaceEntry::NewEntry(iface->name, strlen(iface->name),
|
||||
iface->iid,
|
||||
typelibRecord, aWorkingSet);
|
||||
if(!entry)
|
||||
{
|
||||
|
|
|
@ -360,7 +360,8 @@ PRBool ReadSectionHeader(nsManifestLineReader& reader,
|
|||
*p = 0;
|
||||
|
||||
char* values[2];
|
||||
if(2 != reader.ParseLine(values, 2))
|
||||
int lengths[2];
|
||||
if(2 != reader.ParseLine(values, lengths, 2))
|
||||
break;
|
||||
|
||||
// ignore the leading '['
|
||||
|
@ -395,6 +396,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
int dir;
|
||||
int flags;
|
||||
char* values[6]; // 6 is currently the max items we need to parse
|
||||
int lengths[6];
|
||||
PRUint32 size32;
|
||||
PRInt64 size;
|
||||
PRInt64 date;
|
||||
|
@ -427,7 +429,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,VersionLiteral,major,minor
|
||||
if(4 != reader.ParseLine(values, 4))
|
||||
if(4 != reader.ParseLine(values, lengths, 4))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -452,7 +454,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,AppDirLiteral,directoryname
|
||||
if(3 != reader.ParseLine(values, 3))
|
||||
if(3 != reader.ParseLine(values, lengths, 3))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -493,7 +495,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,directoryname
|
||||
if(2 != reader.ParseLine(values, 2))
|
||||
if(2 != reader.ParseLine(values, lengths, 2))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -524,7 +526,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,filename,dirIndex,dilesSize,filesDate
|
||||
if(5 != reader.ParseLine(values, 5))
|
||||
if(5 != reader.ParseLine(values, lengths, 5))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -576,7 +578,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,filename
|
||||
if(2 != reader.ParseLine(values, 2))
|
||||
if(2 != reader.ParseLine(values, lengths, 2))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -611,7 +613,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
goto out;
|
||||
|
||||
// index,interfaceName,iid,fileIndex,zipIndex,flags
|
||||
if(6 != reader.ParseLine(values, 6))
|
||||
if(6 != reader.ParseLine(values, lengths, 6))
|
||||
goto out;
|
||||
|
||||
// index
|
||||
|
@ -648,7 +650,8 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
|
|||
else
|
||||
typelibRecord.Init(fileIndex, zipItemIndex);
|
||||
|
||||
entry = xptiInterfaceEntry::NewEntry(values[1], iid, typelibRecord,
|
||||
entry = xptiInterfaceEntry::NewEntry(values[1], lengths[1],
|
||||
iid, typelibRecord,
|
||||
aWorkingSet);
|
||||
if(!entry)
|
||||
goto out;
|
||||
|
|
|
@ -531,6 +531,7 @@ class xptiInterfaceEntry
|
|||
{
|
||||
public:
|
||||
static xptiInterfaceEntry* NewEntry(const char* name,
|
||||
int nameLength,
|
||||
const nsID& iid,
|
||||
const xptiTypelib& typelib,
|
||||
xptiWorkingSet* aWorkingSet);
|
||||
|
|
Загрузка…
Ссылка в новой задаче