aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Wininger2014-04-24 13:30:29 (EDT)
committerAlexandre Montplaisir2014-04-28 17:18:51 (EDT)
commit241ba2b436801aa4112ea7fa6c696e5570360802 (patch)
tree6fbfdf37bec293445e82779e2c058ef1958d9d0a
parent9ea9f3532033f461e59deeb9e250219a0b58ca59 (diff)
downloadorg.eclipse.linuxtools-241ba2b436801aa4112ea7fa6c696e5570360802.zip
org.eclipse.linuxtools-241ba2b436801aa4112ea7fa6c696e5570360802.tar.gz
org.eclipse.linuxtools-241ba2b436801aa4112ea7fa6c696e5570360802.tar.bz2
tmf: HTNode coding style improvement.refs/changes/12/25512/4
Change-Id: I9f298cdff2d583a738d7926ad5ba2b0fcd07bd9d Signed-off-by: Florian Wininger <florian.wininger@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/25512 Tested-by: Hudson CI Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.statesystem.core/src/org/eclipse/linuxtools/internal/statesystem/core/backend/historytree/HTNode.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.statesystem.core/src/org/eclipse/linuxtools/internal/statesystem/core/backend/historytree/HTNode.java b/lttng/org.eclipse.linuxtools.statesystem.core/src/org/eclipse/linuxtools/internal/statesystem/core/backend/historytree/HTNode.java
index 8e7b289..ab1ef7b 100644
--- a/lttng/org.eclipse.linuxtools.statesystem.core/src/org/eclipse/linuxtools/internal/statesystem/core/backend/historytree/HTNode.java
+++ b/lttng/org.eclipse.linuxtools.statesystem.core/src/org/eclipse/linuxtools/internal/statesystem/core/backend/historytree/HTNode.java
@@ -394,7 +394,7 @@ public abstract class HTNode {
try {
assert (endtime >= this.nodeStart);
- if (intervals.size() > 0) {
+ if (!intervals.isEmpty()) {
/*
* Sort the intervals by ascending order of their end time. This
* speeds up lookups a bit
@@ -433,12 +433,7 @@ public abstract class HTNode {
/* This is from a state system query, we are "reading" this node */
rwl.readLock().lock();
try {
- if (intervals.size() == 0) {
- return;
- }
- int startIndex = getStartIndexFor(t);
-
- for (int i = startIndex; i < intervals.size(); i++) {
+ for (int i = getStartIndexFor(t); i < intervals.size(); i++) {
/*
* Now we only have to compare the Start times, since we now the
* End times necessarily fit.
@@ -474,13 +469,7 @@ public abstract class HTNode {
public HTInterval getRelevantInterval(int key, long t) throws TimeRangeException {
rwl.readLock().lock();
try {
- if (intervals.size() == 0) {
- return null;
- }
-
- int startIndex = getStartIndexFor(t);
-
- for (int i = startIndex; i < intervals.size(); i++) {
+ for (int i = getStartIndexFor(t); i < intervals.size(); i++) {
HTInterval curInterval = intervals.get(i);
if (curInterval.getAttribute() == key
&& curInterval.getStartTime() <= t
@@ -488,6 +477,7 @@ public abstract class HTNode {
return curInterval;
}
}
+
/* We didn't find the relevant information in this node */
return null;
@@ -498,6 +488,10 @@ public abstract class HTNode {
private int getStartIndexFor(long t) throws TimeRangeException {
/* Should only be called by methods with the readLock taken */
+
+ if (intervals.isEmpty()) {
+ return 0;
+ }
/*
* Since the intervals are sorted by end time, we can skip all the ones
* at the beginning whose end times are smaller than 't'. Java does