Skip to content

Commit

Permalink
Make profiling correctly handle the same file being opened multiple t…
Browse files Browse the repository at this point in the history
…imes
  • Loading branch information
ChrisJefferson committed Jan 13, 2017
1 parent 7c91a62 commit d1af6de
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#include "code.h" /* coder */

#include "bool.h" /* For fail */

#include "saveload.h" /* saving and loading */
#include "read.h" /* to access stack of for loop globals */
#include "gvars.h"
Expand Down Expand Up @@ -120,14 +122,23 @@ static inline void PopLoopNesting( void ) {
static inline void setup_gapname(TypInputFile* i)
{
UInt len;
Obj pos;
if(!i->gapname) {
C_NEW_STRING_DYN(i->gapname, i->name);
len = LEN_PLIST( FilenameCache );
GROW_PLIST( FilenameCache, len+1 );
SET_LEN_PLIST( FilenameCache, len+1 );
SET_ELM_PLIST( FilenameCache, len+1, i->gapname );
CHANGED_BAG( FilenameCache );
i->gapnameid = len+1;
pos = POS_LIST( FilenameCache, i->gapname, INTOBJ_INT(1) );
if(pos == Fail) {
len = LEN_PLIST( FilenameCache );
GROW_PLIST( FilenameCache, len+1 );
SET_LEN_PLIST( FilenameCache, len+1 );
SET_ELM_PLIST( FilenameCache, len+1, i->gapname );
CHANGED_BAG( FilenameCache );
i->gapnameid = len + 1;
}
else {
i->gapnameid = INT_INTOBJ(pos);
// Use string from FilenameCache as we know it will not get GCed
i->gapname = ELM_LIST( FilenameCache, i->gapnameid );
}
}
}

Expand Down

0 comments on commit d1af6de

Please sign in to comment.