Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java31
1 files changed, 13 insertions, 18 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java
index a732315be0..c33692c37c 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java
@@ -15,8 +15,9 @@ package org.eclipse.linuxtools.internal.ctf.core.trace;
import java.io.Serializable;
import java.util.Comparator;
+import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
-
+import org.eclipse.linuxtools.ctf.core.trace.Utils;
/**
* <b><u>StreamInputReaderTimestampComparator</u></b>
@@ -36,25 +37,19 @@ public class StreamInputReaderTimestampComparator implements
// Operations
// ------------------------------------------------------------------------
+ /**
+ * @throws NullPointerException
+ * If any {@link StreamInputReader} parameter is null, of if any
+ * of them does not contain a current event.
+ */
@Override
public int compare(StreamInputReader a, StreamInputReader b) {
- // TODO: use unsigned comparison to avoid sign errors if needed
- if (a.getCurrentEvent() == null) {
- return 0;
- }
- if (b.getCurrentEvent() == null) {
- return 0;
- }
- long ta = a.getCurrentEvent().getTimestamp();
- long tb = b.getCurrentEvent().getTimestamp();
-
- if (ta < tb) {
- return -1;
- } else if (ta > tb) {
- return 1;
- } else {
- return 0;
- }
+ EventDefinition event_a = a.getCurrentEvent();
+ EventDefinition event_b = b.getCurrentEvent();
+
+ long ta = event_a.getTimestamp();
+ long tb = event_b.getTimestamp();
+ return Utils.unsignedCompare(ta, tb);
}
}

Back to the top