henix / blog

some notes
0 stars 0 forks source link

Loitering #21

Open henix opened 10 years ago

henix commented 10 years ago

Holding a reference to an object when it is no longer needed.

public String pop()
{ return s[--N]; }

better:

public String pop() {
    String item = s[--N];
    s[N] = null; // avoid loitering
    return item;
}