Tweak algorithm to match perfbar.c from dl.