fix some O(N) and O(N^2) operations in parallel.map

some left over code from (presumably) when the map partitioning objects
were stateful made the current implemenation O(N^2),
thus crazy slow for much more than a thousand tasks.

A decorator has also been fixed to avoid calling itself more than once in a given context.

An O(N) operation when `TaskScheduler.hwm != 0` has also been fixed.

Illustration of performance differences:

http://nbviewer.ipython.org/5267262

closes #3106