Performance improvement partially addressing issue
If both sets of addedOperations and removedOperations exceed 100 elements,
then checkForOperationMoves(addedOperations, removedOperations) is not called.
This threshold is arbitrary, and does not affect the precision and recall of RefactoringMiner on the current oracle.
@@ -29,6 +29,7 @@ import java.util.TreeSet;
import org.refactoringminer.api.Refactoring;
public class UMLModelDiff {
+ private static final int MAXIMUM_NUMBER_OF_COMPARED_METHODS = 100;
private List<UMLClass> addedClasses;
private List<UMLClass> removedClasses;
@@ -1049,8 +1050,10 @@ public class UMLModelDiff {
for(UMLClass removedClass : removedClasses) {
removedOperations.addAll(removedClass.getOperations());
}
+ if(removedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS || addedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS) {
checkForOperationMoves(addedOperations, removedOperations);
}
+ }
private void checkForOperationMovesIncludingAddedClasses() {
List<UMLOperation> addedOperations = getAddedOperationsInCommonClasses();
@@ -1061,14 +1064,18 @@ public class UMLModelDiff {
/*for(UMLClass removedClass : removedClasses) {
removedOperations.addAll(removedClass.getOperations());
}*/
+ if(removedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS || addedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS) {
checkForOperationMoves(addedOperations, removedOperations);
}
+ }
private void checkForOperationMovesBetweenCommonClasses() {
List<UMLOperation> addedOperations = getAddedOperationsInCommonClasses();
List<UMLOperation> removedOperations = getRemovedOperationsInCommonClasses();
+ if(removedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS || addedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS) {
checkForOperationMoves(addedOperations, removedOperations);
}
+ }
private void checkForOperationMovesBetweenRemovedAndAddedClasses() {
Set<UMLType> interfacesImplementedByAddedClasses = new LinkedHashSet<UMLType>();
@@ -1093,7 +1100,7 @@ public class UMLModelDiff {
removedOperations.addAll(removedClass.getOperations());
}
}
- if(removedOperations.size() <= 100 || addedOperations.size() <= 100) {
+ if(removedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS || addedOperations.size() <= MAXIMUM_NUMBER_OF_COMPARED_METHODS) {
checkForOperationMoves(addedOperations, removedOperations);
}
}
