In some cases, boxing can be source of significant performance penalty, especially in loops.
Some heuristics are applied to estimate the number of boxing operations, for example, conversions inside the loop considered as much more common.Example:
public void example() {
Integer value = 12;
needBox(value);
for (int i = 0; i < 10; i++) {
// Loop usages considered as happening more often
needPrimitive(value);
}
}
void needPrimitive(int value) {}
void needBox(Integer value) {}
After the quick-fix is applied the result looks like:
public void example() {
int value = 12;
needBox(value);
for (int i = 0; i < 10; i++) {
// Loop usages considered as happening more often
needPrimitive(value);
}
}
void needPrimitive(int value) {}
void needBox(Integer value) {}
New in 2018.2