aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-01-10 11:35:38 (EST)
committerAlexander Kurtakov2013-01-10 11:54:37 (EST)
commit24f412afc04907dd92853755e78822f37e53c279 (patch)
tree3752f3f02cad739abce4ee1b405af53b852d01bd
parentfe61701aa6726f70dd2b101069e738bcd57bff37 (diff)
downloadorg.eclipse.linuxtools-24f412afc04907dd92853755e78822f37e53c279.zip
org.eclipse.linuxtools-24f412afc04907dd92853755e78822f37e53c279.tar.gz
org.eclipse.linuxtools-24f412afc04907dd92853755e78822f37e53c279.tar.bz2
Collapse if statements where possible in callgraph plug-ins.refs/changes/86/9586/2
Change-Id: I8620f4f23065beb2dc4e86a5b2c542c31b78c010 Reviewed-on: https://git.eclipse.org/r/9586 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java18
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java30
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapData.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraph.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeListener.java8
6 files changed, 33 insertions, 45 deletions
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
index e136d23..1511fed 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/LaunchStapGraph.java
@@ -139,10 +139,10 @@ public class LaunchStapGraph extends SystemTapLaunchShortcut {
StringBuffer output = new StringBuffer();
for (String func : toWrite.split(" ")) { //$NON-NLS-1$
- if (func.length() > 0) {
- if (exclusions == null || exclusions.size() < 1 || exclusions.contains(func) ) {
- output.append(generateProbe(func));
- }
+ if (func.length() > 0
+ && (exclusions == null || exclusions.size() < 1 || exclusions
+ .contains(func))) {
+ output.append(generateProbe(func));
}
}
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java
index 0665e87..81d77c1 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/ListTreeContentProvider.java
@@ -60,12 +60,12 @@ public class ListTreeContentProvider implements ITreeContentProvider {
try {
for (ICElement child : cont.getChildren()) {
- if (child instanceof ICElement)
- if (SystemTapLaunchShortcut.validElement(child))
- return true;
- if (child instanceof ICContainer) {
- if (checkForValidChildren((ICContainer) child))
- return true;
+ if ((child instanceof ICElement)
+ && SystemTapLaunchShortcut.validElement(child))
+ return true;
+ if ((child instanceof ICContainer)
+ && checkForValidChildren((ICContainer) child)) {
+ return true;
}
}
} catch (CModelException e) {
@@ -106,9 +106,9 @@ public class ListTreeContentProvider implements ITreeContentProvider {
ArrayList<ICElement> output = new ArrayList<ICElement>();
for (ICElement item : array) {
- if (item instanceof ICContainer) {
- if (checkForValidChildren((ICContainer) item))
- output.add(item);
+ if ((item instanceof ICContainer)
+ && checkForValidChildren((ICContainer) item)) {
+ output.add(item);
}
if (SystemTapLaunchShortcut.validElement(item))
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
index 1f65f6b..6556577 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph.launch/src/org/eclipse/linuxtools/internal/callgraph/launch/SystemTapLaunchShortcut.java
@@ -178,11 +178,10 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
.getLaunchManager().getLaunchConfigurations(configType);
for (int i = 0; i < configs.length; i++) {
- if (configs[i] != null && configs[i].exists()) {
- if (checkIfAttributesAreEqual(wc, configs[i])){
- config = configs[i];
- return true;
- }
+ if (configs[i] != null && configs[i].exists()
+ && checkIfAttributesAreEqual(wc, configs[i])) {
+ config = configs[i];
+ return true;
}
}
@@ -679,12 +678,10 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
if (!output.contains(c))
output.add(c);
}
- } else if (obj instanceof ICElement) {
- if (validElement((ICElement) obj)) {
- if (!output.contains(obj)) {
- output.add(obj);
- }
- }
+ } else if ((obj instanceof ICElement)
+ && validElement((ICElement) obj)
+ && !output.contains(obj)) {
+ output.add(obj);
}
}
@@ -709,14 +706,13 @@ public abstract class SystemTapLaunchShortcut extends ProfileLaunchShortcut {
output += numberOfValidFiles(((ICContainer) ele)
.getChildren());
}
- if (ele instanceof ICElement) {
- if (validElement(ele))
- output++;
+ if ((ele instanceof ICElement) && validElement(ele)) {
+ output++;
}
}
- } else if (parent instanceof ICElement) {
- if (validElement((ICElement) parent))
- output++;
+ } else if ((parent instanceof ICElement)
+ && validElement((ICElement) parent)) {
+ output++;
}
}
return output;
diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapData.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapData.java
index a59a76d..2959f4d 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapData.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapData.java
@@ -67,11 +67,9 @@ public class StapData {
//Add this data to the caller's list of IDs
- if (this.parent != -1) {
- if (graphModel.getNodeData(this.parent) != null) {
- graphModel.getNodeData(this.parent).addCallee(this.id);
- this.levelOfRecursion = graphModel.getNodeData(this.parent).levelOfRecursion + 1;
- }
+ if (this.parent != -1 && graphModel.getNodeData(this.parent) != null) {
+ graphModel.getNodeData(this.parent).addCallee(this.id);
+ this.levelOfRecursion = graphModel.getNodeData(this.parent).levelOfRecursion + 1;
}
//---------------Recursion management
diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraph.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraph.java
index 95a29c5..2c710c8 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraph.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/StapGraph.java
@@ -630,10 +630,8 @@ public class StapGraph extends Graph {
StapData data = getNodeData(rootVisibleNodeNumber);
- if (data.children != null) {
- if (data.children.size() < 1) {
- return;
- }
+ if (data.children != null && data.children.size() < 1) {
+ return;
}
List<Integer> list = data.children;
diff --git a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeListener.java b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeListener.java
index 7b9c09e..8993f71 100644
--- a/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeListener.java
+++ b/systemtap/org.eclipse.linuxtools.callgraph/src/org/eclipse/linuxtools/internal/callgraph/treeviewer/StapTreeListener.java
@@ -35,14 +35,10 @@ public class StapTreeListener implements ITreeViewerListener{
@Override
public void treeCollapsed(TreeExpansionEvent event) {
StapData data = (StapData) event.getElement();
- if (highestLevelNodes.get(highestLevelOfExpansion) != null) {
- if (highestLevelNodes.get(highestLevelOfExpansion).remove((Integer) data.id)) {
+ if (highestLevelNodes.get(highestLevelOfExpansion) != null
+ && highestLevelNodes.get(highestLevelOfExpansion).remove((Integer) data.id)) {
scrollbar.setSelection(scrollbar.getSelection() - INCREMENT);
- // scrollbar.setMaximum(scrollbar.getMaximum() - scrollbar.getThumb() - INCREMENT);
- // if (highestLevelNodes.size() == 0) {
highestLevelOfExpansion--;
- // }
- }
}
}