Cache 'logs.length', please. 

for (var i = 0, j = logs.length; i < j; i++)

The same applies for the whole patch.