Skip to content

Commit

Permalink
Merge pull request #21 from Haiyang-Sun/sourcemapping-improve
Browse files Browse the repository at this point in the history
make the iidToLocation string cache on-demand to save memory
  • Loading branch information
Haiyang-Sun authored Jan 21, 2019
2 parents b1b9f88 + 5288419 commit 33d35c4
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ public static int getIIDForSourceSection(SourceSection sourceSection) {
}
int newIId = ++iidGen;
assert (newIId < Integer.MAX_VALUE);
StringBuilder b = makeLocationString(sourceSection);

iidMap.put(newIId, b.toString());
sourceSet.put(sourceSection, newIId);
idToSource.put(newIId, sourceSection);
return newIId;
}

@TruffleBoundary
public static String getLocationForIID(int iid) {
return iidMap.get(iid);
if (iidMap.containsKey(iid)) {
return iidMap.get(iid);
} else if (idToSource.containsKey(iid)) {
String res = makeLocationString(idToSource.get(iid)).toString();
iidMap.put(iid, res);
return res;
} else {
return null;
}
}

@TruffleBoundary
Expand Down

0 comments on commit 33d35c4

Please sign in to comment.