Use candidates-in-buffer to improve performances

Hi Le,
here a small pull-request just to allow you seeing the diff.
Using `candidates-in-buffer` here improve performances but will be harder to use in some places where you want to dynamically compute candidates.