Commit 7708e877 authored by Sindre Sorhus's avatar Sindre Sorhus

Optimize loop

parent 8ad3e2dd
......@@ -89,10 +89,11 @@ jQuery(function($) {
this.$clearBtn.text( clearTitle ).toggle( !!completedTodos );
},
destroyDone: function() {
// Reverse loop; since we are dynamically removing items from the todos array
for ( var i = App.todos.length; i--; ) {
if ( App.todos[i].done ) {
App.todos.remove(i);
var todos = App.todos,
l = todos.length;
while ( l-- ) {
if ( todos[l].done ) {
todos.remove(l);
}
}
App.render();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment