diff options
author | Etienne Bergeron | 2013-11-24 05:52:17 +0000 |
---|---|---|
committer | Alexandre Montplaisir | 2013-11-26 19:43:16 +0000 |
commit | 75e41738707e0e8cd4334a634280fc39e88bb9c1 (patch) | |
tree | 439affb252114ee1b94fadae372ad3a3242841d8 | |
parent | f61578e055c4f89433a366bdbed722bc80dae872 (diff) | |
download | org.eclipse.linuxtools-75e41738707e0e8cd4334a634280fc39e88bb9c1.tar.gz org.eclipse.linuxtools-75e41738707e0e8cd4334a634280fc39e88bb9c1.tar.xz org.eclipse.linuxtools-75e41738707e0e8cd4334a634280fc39e88bb9c1.zip |
ctf: Plug the unsigned utils comparator into Stream comparator.
This patch-set fixes a pending TODO found randomly.
It modifies the code to use the unsigned comparator and avoid
bugs for large timestamp values.
The comparator no longer accept null values.
Change-Id: Idee0e56edfe85ba01a27fb79d1076736fee24874
Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/18785
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r-- | lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputReaderTimestampComparator.java | 31 |
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); } } |