Fix performance problem when generating many values for # register
Fix performance problem when generating many values for # register

Fixes #2008

jkonecny12/kakoune,Somasis/kakoune,occivink/kakoune,occivink/kakoune,jjthrash/kakoune,danr/kakoune,mawww/kakoune,mawww/kakoune,danr/kakoune,Somasis/kakoune,Somasis/kakoune,jkonecny12/kakoune,lenormf/kakoune,casimir/kakoune,occivink/kakoune,occivink/kakoune,Somasis/kakoune,jjthrash/kakoune,mawww/kakoune,jjthrash/kakoune,alexherbo2/kakoune,lenormf/kakoune,jjthrash/kakoune,lenormf/kakoune,alexherbo2/kakoune,danr/kakoune,mawww/kakoune,danr/kakoune,casimir/kakoune,alexherbo2/kakoune,lenormf/kakoune,alexherbo2/kakoune,jkonecny12/kakoune,jkonecny12/kakoune,casimir/kakoune,casimir/kakoune