Skip to content

Commit aa81ca9

Browse files
committed
Cleanup and optimize use of EMO flag byte
1 parent e96963c commit aa81ca9

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/projections/Tools/Timeline/EntryMethodObject.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ public Extra(TimelineEvent tle) {
8787
private static DecimalFormat format_ = new DecimalFormat();
8888

8989
private final byte epFlags;
90-
private static final byte COMM_THD_RECV_MASK = 0x1;
91-
private static final byte IDLE_EP_MASK = 0x2;
92-
private static final byte OVERHEAD_EP_MASK = 0x4;
90+
91+
private static final byte IS_IDLE_EP = 0x1;
92+
private static final byte IS_OVERHEAD_EP = 0x2;
93+
private static final byte IS_COMM_THD_RECV = 0x4;
94+
95+
// Specifies which flag bits represent the type of the EP (e.g. idle, overhead)
96+
private static final byte EP_TYPE_MASK = 0x3;
9397

9498
protected EntryMethodObject(Data data, TimelineEvent tle,
9599
ArrayList<TimelineMessage> msgs, ArrayList<PackTime> packs,
@@ -106,15 +110,15 @@ protected EntryMethodObject(Data data, TimelineEvent tle,
106110
final int myNode = data.getNodeID(pe);
107111
final int creationNode = data.getNodeID(pCreation);
108112
if (myNode != creationNode)
109-
flags |= COMM_THD_RECV_MASK;
113+
flags |= IS_COMM_THD_RECV;
110114
}
111115

112116
switch (tle.EntryPoint) {
113117
case Analysis.IDLE_ENTRY_POINT:
114-
flags |= IDLE_EP_MASK;
118+
flags |= IS_IDLE_EP;
115119
break;
116120
case Analysis.OVERHEAD_ENTRY_POINT:
117-
flags |= OVERHEAD_EP_MASK;
121+
flags |= IS_OVERHEAD_EP;
118122
break;
119123
default:
120124
entryPoint = (short)tle.EntryPoint;
@@ -360,11 +364,13 @@ public long getEndTime()
360364
return beginTime + elapsedTime;
361365
}
362366

363-
public int getEntry()
367+
public final int getEntry()
364368
{
365-
if (isIdleEvent()) return Analysis.IDLE_ENTRY_POINT;
366-
else if (isUnaccountedTime()) return Analysis.OVERHEAD_ENTRY_POINT;
367-
else return Short.toUnsignedInt(entryPoint);
369+
switch (epFlags & EP_TYPE_MASK) {
370+
case IS_IDLE_EP: return Analysis.IDLE_ENTRY_POINT;
371+
case IS_OVERHEAD_EP: return Analysis.OVERHEAD_ENTRY_POINT;
372+
default: return Short.toUnsignedInt(entryPoint);
373+
}
368374
}
369375

370376
public int getEntryIndex()
@@ -784,12 +790,12 @@ private void OpenMessageWindow()
784790
}
785791

786792
/** Is this an idle event */
787-
public boolean isIdleEvent(){
788-
return getFlag(IDLE_EP_MASK);
793+
public final boolean isIdleEvent(){
794+
return getFlag(IS_IDLE_EP);
789795
}
790796

791-
public boolean isUnaccountedTime(){
792-
return getFlag(OVERHEAD_EP_MASK);
797+
public final boolean isUnaccountedTime(){
798+
return getFlag(IS_OVERHEAD_EP);
793799
}
794800

795801

@@ -1137,7 +1143,7 @@ public ObjectId getTid() {
11371143
}
11381144

11391145
public boolean isCommThreadMsgRecv(){
1140-
return getFlag(COMM_THD_RECV_MASK);
1146+
return getFlag(IS_COMM_THD_RECV);
11411147
}
11421148

11431149
/** Shift all the times associated with this entry method by given amount */

0 commit comments

Comments
 (0)