Optimize the `Ref` class in `src/core/primitives.js`
Optimize the `Ref` class in `src/core/primitives.js`

The `toString` method always creates two string objects (for the 'R'
character and for the `num` concatenation) and in the worst case
creates three string objects (one more for the `gen` concatenation).
For the Tracemonkey paper alone, this resulted in 12000 string
objects when scrolling from the top to the bottom of the document.
Since this is a hot function, it's worth minimizing the number of string
objects, especially for large documents, to reduce peak memory usage.

This commit refactors the `toString` method to always create only one
string object.

caremerge/pdf.js,Snuffleupagus/pdf.js,timvandermeij/pdf.js,xavier114fch/pdf.js,Shoobx/pdf.js,showpad/mozilla-pdf.js,mozilla/pdf.js,nawawi/pdf.js,mozilla/pdf.js,macroplant/pdf.js,nawawi/pdf.js,timvandermeij/pdf.js,Snuffleupagus/pdf.js,Snuffleupagus/pdf.js,macroplant/pdf.js,Shoobx/pdf.js,mukulmishra18/pdf.js,nawawi/pdf.js,mainegreen/pdf.js,xavier114fch/pdf.js,showpad/mozilla-pdf.js,timvandermeij/pdf.js,macroplant/pdf.js,Shoobx/pdf.js,mukulmishra18/pdf.js,mainegreen/pdf.js,showpad/mozilla-pdf.js,mozilla/pdf.js,caremerge/pdf.js