Refactor the core of choosing by weights into a function

This eliminates duplicated code, and lets us test a hairy piece of
functionality.
This commit is contained in:
Nick Mathewson
2012-08-09 13:47:42 -04:00
parent 9bfb274abb
commit 07df4dd52d
5 changed files with 160 additions and 96 deletions
+4
View File
@@ -10,3 +10,7 @@
than it ran through the part of the loop before it had made its
choice. Fix for bug 6538.
o Code simplifications and refactoring:
- Move the core of our "choose a weighted element at random" logic
into its own function, and give it unit tests. Now the logic is
testable, and a little less fragile too.