Skip to content

Commit 0852d35

Browse files
committed
Cleanup uses of oidToEntryMethodObjectsMap
Previously the collection of EMOs was a Set being stored as the value in a <ObjectID, List> map. This change makes the actual collection into a List to both match types and save space.
1 parent 5dbda94 commit 0852d35

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/projections/Tools/Timeline/Data.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ protected void createTLOArray(boolean useHelperThreads, Component rootWindow, bo
670670
{
671671
topTimesText = "<html>";
672672
topTimesText+="The longest idle times in descending order are: <br>";
673-
Set<EntryMethodObject> longestObjectsSet = new HashSet<EntryMethodObject>();
673+
HashSet<EntryMethodObject> longestObjectsSet = new HashSet<EntryMethodObject>();
674674
for (int i = 0; i < amountTopTimes(); i++)
675675
{
676676
if ((idleArray[i] == null) || (idleArray[i].getBeginTime() == objEndTimes[i]))
@@ -693,9 +693,7 @@ protected void createTLOArray(boolean useHelperThreads, Component rootWindow, bo
693693
longestObjectsSet.add(entryArray[i]);
694694
}
695695
topTimesText+="</html>";
696-
HashSet<Object> objsToHilite = new HashSet<Object>();
697-
objsToHilite.addAll(longestObjectsSet);
698-
highlightObjects(objsToHilite);
696+
highlightObjects(longestObjectsSet);
699697
}
700698

701699
// Spawn a thread that computes some secondary message related data structures
@@ -1521,15 +1519,15 @@ protected void clearObjectHighlights() {
15211519
}
15221520

15231521
/** Highlight the given set of timeline objects */
1524-
protected void highlightObjects(Set<Object> objects) {
1522+
protected void highlightObjects(Collection<EntryMethodObject> objects) {
15251523
highlightedObjects.addAll(objects);
15261524
}
15271525

15281526
/** Determine if an object should be dimmed.
15291527
* If there are any objects set to be highlighted,
15301528
* all others will be dimmed
15311529
*/
1532-
protected boolean isObjectDimmed(Object o){
1530+
protected boolean isObjectDimmed(EntryMethodObject o){
15331531
if(highlightedObjects.size() == 0)
15341532
return false;
15351533
else

src/projections/Tools/Timeline/EntryMethodObject.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ public void mouseClicked(MouseEvent evt, JPanel parent, Data data)
452452
Set<EntryMethodObject> back = traceBackwardDependencies();// this function acts differently depending on data.traceMessagesBackOnHover()
453453
Set<EntryMethodObject> criticalpath = traceCriticalPathDependencies();// this function acts differently depending on data.traceMessagesBackOnHover()
454454

455-
HashSet<Object> fwdGeneric = new HashSet<Object>();
456-
HashSet<Object> backGeneric = new HashSet<Object>();
457-
HashSet<Object> criticalpathGeneric = new HashSet<Object>();
455+
HashSet<EntryMethodObject> fwdGeneric = new HashSet<>();
456+
HashSet<EntryMethodObject> backGeneric = new HashSet<>();
457+
HashSet<EntryMethodObject> criticalpathGeneric = new HashSet<>();
458458
fwdGeneric.addAll(fwd); // this function acts differently depending on data.traceMessagesForwardOnHover()
459459
backGeneric.addAll(back); // this function acts differently depending on data.traceMessagesBackOnHover()
460460
criticalpathGeneric.addAll(criticalpath); // this function acts differently depending on data.traceCriticalPathOnHover()
@@ -734,7 +734,7 @@ public void mouseEntered(MouseEvent evt)
734734
// Highlight any Entry Method invocations for the same chare array element
735735
if(data.traceOIDOnHover()){
736736
synchronized(data.messageStructures){
737-
Set allWithSameId = (Set) data.messageStructures.getOidToEntryMethodObjectsMap().get(tid);
737+
List<EntryMethodObject> allWithSameId = data.messageStructures.getOidToEntryMethodObjectsMap().get(tid);
738738
data.highlightObjects(allWithSameId);
739739
needRepaint=true;
740740
}

src/projections/Tools/Timeline/MessageStructures.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package projections.Tools.Timeline;
22

3+
import java.util.ArrayList;
34
import java.util.HashMap;
45
import java.util.Iterator;
56
import java.util.List;
67
import java.util.Map;
7-
import java.util.Set;
88
import java.util.TreeMap;
9-
import java.util.TreeSet;
109

1110
import projections.Tools.Timeline.RangeQueries.Query1D;
1211
import projections.analysis.ObjectId;
@@ -56,7 +55,7 @@ private void init(){
5655
for(int i=0;i<pe;i++)
5756
eventIDToEntryMethodMap[i] = new HashMap();
5857

59-
oidToEntryMethodObjectsMap = new TreeMap();
58+
oidToEntryMethodObjectsMap = new TreeMap<>();
6059
}
6160
}
6261

@@ -87,7 +86,7 @@ public void setOidToEntryMethodObjectsMap(Map oidToEntryMethodObjectsMap) {
8786
this.oidToEntryMethodObjectsMap = oidToEntryMethodObjectsMap;
8887
}
8988

90-
public Map getOidToEntryMethodObjectsMap() {
89+
public Map<ObjectId, List<EntryMethodObject>> getOidToEntryMethodObjectsMap() {
9190
return oidToEntryMethodObjectsMap;
9291
}
9392

@@ -204,11 +203,11 @@ protected void generate(ThreadMessageStructures structures){
204203

205204
if(getOidToEntryMethodObjectsMap().containsKey(id)){
206205
// add obj to the existing set
207-
TreeSet<EntryMethodObject> s = (TreeSet<EntryMethodObject>) getOidToEntryMethodObjectsMap().get(id);
206+
List<EntryMethodObject> s = getOidToEntryMethodObjectsMap().get(id);
208207
s.add(obj);
209208
} else {
210209
// create a set for the id
211-
TreeSet<EntryMethodObject> s = new TreeSet<EntryMethodObject>();
210+
ArrayList<EntryMethodObject> s = new ArrayList<EntryMethodObject>();
212211
s.add(obj);
213212
getOidToEntryMethodObjectsMap().put(id, s);
214213
}

0 commit comments

Comments
 (0)