Optimize common cases in hexToStr().
This avoids the creation of over two million array objects when viewing http://www.dynacw.co.jp/Portals/3/fontsamplepdf/sample_4942546800828.pdf, and reduces load time from 76 to 73 ms.
This commit is contained in:
parent
c7f02d2c8e
commit
501446ccc4
@ -313,6 +313,14 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hexToStr(a, size) {
|
function hexToStr(a, size) {
|
||||||
|
// This code is hot. Special-case some common values to avoid creating an
|
||||||
|
// object with subarray().
|
||||||
|
if (size == 1) {
|
||||||
|
return String.fromCharCode(a[0], a[1]);
|
||||||
|
}
|
||||||
|
if (size == 3) {
|
||||||
|
return String.fromCharCode(a[0], a[1], a[2], a[3]);
|
||||||
|
}
|
||||||
return String.fromCharCode.apply(null, a.subarray(0, size + 1));
|
return String.fromCharCode.apply(null, a.subarray(0, size + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user