Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

avoid allocating arrays for min/max calculation

No need to generate more garbage for the GC to chomp on in
a hot code path.  This is a noticeable improvement under
Ruby 1.9.2 on trivial code where the app primarily aggregates.
  • Loading branch information...
commit ba884f197bbe6aa8a04dec7355ac369932cf7b5b 1 parent 387d874
Eric Wong authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/aggregate.rb
View
4 lib/aggregate.rb
@@ -72,8 +72,8 @@ def << data
@min = data
@max = data
else
- @max = [data, @max].max
- @min = [data, @min].min
+ @max = data if data > @max
+ @min = data if data < @min
end
# Update the running info
Please sign in to comment.
Something went wrong with that request. Please try again.