chiark / gitweb /
choose: Use a one-pass algorithm to select tracks.
authormdw@distorted.org.uk <>
Sun, 20 Apr 2008 18:36:32 +0000 (19:36 +0100)
committermdw@distorted.org.uk <>
Sun, 20 Apr 2008 18:36:32 +0000 (19:36 +0100)
commit74b1f70dbce97198dc741ddd61214e55138f826f
tree5a7e798f27ce9d0c4873aec4a3ac204730b0fe52
parent4005a0d66ea1aea1475088c998d35f16ef800bba
choose: Use a one-pass algorithm to select tracks.

The previous algorithm used one pass over the track database to compute
weights and build a list, and a second pass to pick the right track from
the list after having actually chosen a random number,

This change throws out a lot of the old code involved with constructing
and walking the list by using a one-pass algorithm instead.  (The
algorithm provably preserves the probability distribution: see
commentary.)
server/choose.c