Skip to content

Commit

Permalink
Factorize the line probe condition for evluateAt
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbempel committed Nov 2, 2023
1 parent 69b777a commit 810c321
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,14 @@ public Status evaluate(
ValueReferences.DURATION_EXTENSION_NAME, duration / 1_000_000.0); // convert to ms
}
this.thisClassName = thisClassName;
boolean shouldEvaluate = resolveEvaluateAt(probeImplementation, methodLocation);
boolean shouldEvaluate =
MethodLocation.isSame(methodLocation, probeImplementation.getEvaluateAt());
if (shouldEvaluate) {
probeImplementation.evaluate(this, status, methodLocation);
}
return status;
}

private static boolean resolveEvaluateAt(
ProbeImplementation probeImplementation, MethodLocation methodLocation) {
if (methodLocation == MethodLocation.DEFAULT) {
// line probe, no evaluation of probe's evaluateAt
return true;
}
return MethodLocation.isSame(methodLocation, probeImplementation.getEvaluateAt());
}

public Status getStatus(String probeId) {
Status result = statusByProbeId.get(probeId);
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public enum MethodLocation {

public static boolean isSame(MethodLocation methodLocation, MethodLocation evaluateAt) {
if (methodLocation == MethodLocation.DEFAULT) {
// line probe always assume we are the right location
// line probe, no evaluation of probe's evaluateAt
return true;
}
if (methodLocation == MethodLocation.ENTRY) {
Expand Down

0 comments on commit 810c321

Please sign in to comment.