@@ -95,6 +95,8 @@ public class Stream {
95
95
96
96
private final MethodInvocation creation ;
97
97
98
+ private Optional <SSAInvokeInstruction > instructionForCreation ;
99
+
98
100
private final MethodDeclaration enclosingMethodDeclaration ;
99
101
100
102
private IR enclosingMethodDeclarationIR ;
@@ -419,24 +421,29 @@ public InstanceKey getInstanceKey(Collection<InstanceKey> trackedInstances,
419
421
420
422
Optional <SSAInvokeInstruction > getInstructionForCreation (EclipseProjectAnalysisEngine <InstanceKey > engine )
421
423
throws InvalidClassFileException , IOException , CoreException {
422
- IBytecodeMethod method = (IBytecodeMethod ) this .getEnclosingMethodIR (engine ).getMethod ();
423
- SimpleName methodName = this .getCreation ().getName ();
424
-
425
- for (Iterator <SSAInstruction > it = this .getEnclosingMethodIR (engine ).iterateNormalInstructions (); it
426
- .hasNext ();) {
427
- SSAInstruction instruction = it .next ();
428
-
429
- int lineNumberFromIR = getLineNumberFromIR (method , instruction );
430
- int lineNumberFromAST = getLineNumberFromAST (methodName );
431
-
432
- if (lineNumberFromIR == lineNumberFromAST ) {
433
- // lines from the AST and the IR match. Let's dive a little
434
- // deeper to be more confident of the correspondence.
435
- if (matches (instruction , this .getCreation (), Optional .of (LOGGER )))
436
- return Optional .of ((SSAInvokeInstruction ) instruction );
424
+ if (this .instructionForCreation == null ) {
425
+ IBytecodeMethod method = (IBytecodeMethod ) this .getEnclosingMethodIR (engine ).getMethod ();
426
+ SimpleName methodName = this .getCreation ().getName ();
427
+
428
+ for (Iterator <SSAInstruction > it = this .getEnclosingMethodIR (engine ).iterateNormalInstructions (); it
429
+ .hasNext ();) {
430
+ SSAInstruction instruction = it .next ();
431
+
432
+ int lineNumberFromIR = getLineNumberFromIR (method , instruction );
433
+ int lineNumberFromAST = getLineNumberFromAST (methodName );
434
+
435
+ if (lineNumberFromIR == lineNumberFromAST ) {
436
+ // lines from the AST and the IR match. Let's dive a little
437
+ // deeper to be more confident of the correspondence.
438
+ if (matches (instruction , this .getCreation (), Optional .of (LOGGER ))) {
439
+ instructionForCreation = Optional .of ((SSAInvokeInstruction ) instruction );
440
+ return instructionForCreation ;
441
+ }
442
+ }
437
443
}
444
+ instructionForCreation = Optional .empty ();
438
445
}
439
- return Optional . empty () ;
446
+ return instructionForCreation ;
440
447
}
441
448
442
449
private JDTIdentityMapper getJDTIdentifyMapperForCreation () {
0 commit comments