Changed distance() to be more memory efficient based on email from mailing list.

Changed the implementation so that it uses a smaller array and overwrites it on loop iterations.

http://forum.dlang.org/thread/rwrjgydeiytufcuiqaqk@forum.dlang.org