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

Optimize loop

parent 8ad3e2dd
...@@ -89,10 +89,11 @@ jQuery(function($) { ...@@ -89,10 +89,11 @@ jQuery(function($) {
this.$clearBtn.text( clearTitle ).toggle( !!completedTodos ); this.$clearBtn.text( clearTitle ).toggle( !!completedTodos );
}, },
destroyDone: function() { destroyDone: function() {
// Reverse loop; since we are dynamically removing items from the todos array var todos = App.todos,
for ( var i = App.todos.length; i--; ) { l = todos.length;
if ( App.todos[i].done ) { while ( l-- ) {
App.todos.remove(i); if ( todos[l].done ) {
todos.remove(l);
} }
} }
App.render(); 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