Permalink
Browse files

cache log(2) value as a constant

  • Loading branch information...
1 parent 0efd394 commit 5c5464ee1b1518717438a872af34298f11a716d1 @josephruscio committed Sep 12, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/aggregate.rb
View
3 lib/aggregate.rb
@@ -276,8 +276,9 @@ def to_index (data)
end
# log2(x) returns j, | i = j-1 and 2**i <= data < 2**j
+ @@LOG2_DIVEDEND = Math.log(2)
def log2( x )
- Math.log(x) / Math.log(2)
+ Math.log(x) / @@LOG2_DIVEDEND
end
end

0 comments on commit 5c5464e

Please sign in to comment.