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:
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) {}
Type may be primitive
Inspection info: Reports local variables of wrapper type that are mostly used as primitive types.
In some cases, boxing can be source of significant performance penalty, especially in loops.
Heuristics are applied to estimate the number of boxing operations. For example, conversions inside loops are considered as much more numerous.
类型可以是原始的
检查信息:报告包装器类型的局部变量,这些变量主要用作原始类型。
在某些情况下,装箱可能会导致显著的性能损失,特别是在循环中。
应用启发式方法估计装箱操作的次数。 例如,循环内部的转换被认为要多得多。
转为原始类型
比如:Double -> double
Integer -> int
Long -> long
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)