From: Matthew Khouzam Date: Sat, 1 Oct 2016 05:25:15 +0000 (-0400) Subject: timing.core: simplify hashCode, equals and toString of AbstractCalledFunction X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=bc84ff5815a0ecd98424cd53ccd88f10898440ac timing.core: simplify hashCode, equals and toString of AbstractCalledFunction * hashcode now uses Objects.hash * equals new uses and Object.equals * toString now avoids a useless new String() Change-Id: Ib409d1eee45a17b917f334d93e52a6845bcd2954 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/82308 Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien Reviewed-by: Hudson CI --- diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/callgraph/AbstractCalledFunction.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/callgraph/AbstractCalledFunction.java index a3138d0df0..0d9833949e 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/callgraph/AbstractCalledFunction.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/callgraph/AbstractCalledFunction.java @@ -138,21 +138,12 @@ abstract class AbstractCalledFunction implements ICalledFunction { @Override public String toString() { - return new String("[" + String.valueOf(fStart) + ", " + String.valueOf(fEnd) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return '[' + String.valueOf(fStart) + ", " + String.valueOf(fEnd) + ']'; //$NON-NLS-1$ } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + fDepth; - result = prime * result + (int) (fEnd ^ (fEnd >>> 32)); - ICalledFunction parent = fParent; - result = prime * result + ((parent == null) ? 0 : parent.hashCode()); - result = prime * result + (int) (fSelfTime ^ (fSelfTime >>> 32)); - result = prime * result + (int) (fStart ^ (fStart >>> 32)); - result = prime * result + getSymbol().hashCode(); - return result; + return Objects.hash(fDepth, fEnd, fParent, fSelfTime, fStart, getSymbol()); } @Override @@ -173,19 +164,15 @@ abstract class AbstractCalledFunction implements ICalledFunction { if (fEnd != other.fEnd) { return false; } - if (fParent == null) { - if (other.fParent != null) { - return false; - } - } else if (!Objects.equals(fParent, other.fParent)) { - return false; - } if (fSelfTime != other.fSelfTime) { return false; } if (fStart != other.fStart) { return false; } + if (!Objects.equals(fParent, other.getParent())) { + return false; + } if (!Objects.equals(getSymbol(), other.getSymbol())) { return false; }