-
@pacoguzman Few things:
- I think we just need
if @populated
, without the|| overflow?
, sinceoverflow?
would itself callpopulate!
, so at that point returning@array.size
or callingcount
wouldn't make a difference, I think. - Would it make sense to set
@populated
fromcount
since we know it runs through the entire loop? -
#real_size
doesn't need to callpopulate!
and checkif @overflow
, it can just doif overflow?
- What's the reason for
diffs.instance_eval { @array.sum(&:added_lines) }
vsdiffs.sum(&:added_lines)
?
- I think we just need
-
Thanks @DouweM what I noticed just trying the previous code in the console is that iterating through the raw collection (@iterator) thing that we always do even when we already populated the @array instance is slow. Probably because rugged is still doing things under the hood, that's why I get some speed boost adding more checks in the code and using
@array
instead.@array.size
vscount
is a win based in my comment above, I would like to measure this isolated but a 3x speed boost in the benchmark above is a thing to notice
Please register or sign in to comment