- replaced a few temporary allocations with TArray and added a few convenience loader functions for this.
Amazingly with today's optimizers this creates code which is just as good as doing it all manually with the added benefit of being safer.
This commit is contained in:
parent
602ea8f723
commit
3448749de6
10 changed files with 60 additions and 39 deletions
|
|
@ -323,15 +323,12 @@ void FParseContext::ParseLump(const char *lumpname)
|
|||
}
|
||||
|
||||
// Read the lump into a buffer and add a 0-terminator
|
||||
int lumplen = Wads.LumpLength(lumpno);
|
||||
char *lumpdata = new char[lumplen+1];
|
||||
Wads.ReadLump(lumpno, lumpdata);
|
||||
lumpdata[lumplen] = 0;
|
||||
auto lumpdata = Wads.ReadLumpIntoArray(lumpno, 1);
|
||||
|
||||
SourceLine = 0;
|
||||
SourceFile = lumpname;
|
||||
|
||||
char *sourcep = lumpdata;
|
||||
char *sourcep = (char*)lumpdata.Data();
|
||||
while ( (tokentype = GetToken(sourcep, &token)) )
|
||||
{
|
||||
// It is much easier to handle include statements outside the main parser.
|
||||
|
|
@ -349,7 +346,6 @@ void FParseContext::ParseLump(const char *lumpname)
|
|||
Parse(pParser, tokentype, token, this);
|
||||
}
|
||||
}
|
||||
delete [] lumpdata;
|
||||
SourceLine = SavedSourceLine;
|
||||
SourceFile = SavedSourceFile;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue