예:
class Item {
// 재사용 가능한 길이가 0인 배열의 Public 상수
public static final Item[] EMPTY_ARRAY = new Item[0];
}
class EmptyNode {
Item[] getChildren() {
// 길이가 0인 배열의 불필요한 생성
return new Item[0];
}
}
빠른 수정을 적용한 후:
class EmptyNode {
Item[] getChildren() {
return Item.EMPTY_ARRAY;
}
}