1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Use Array.join() to build up strings in more places.

This commit is contained in:
Nicholas Nethercote 2014-02-27 15:23:56 -08:00
parent cab5d7b96f
commit ab7568c0ff
3 changed files with 27 additions and 22 deletions

View file

@ -291,11 +291,13 @@ var PDFDocument = (function PDFDocumentClosure() {
function find(stream, needle, limit, backwards) {
var pos = stream.pos;
var end = stream.end;
var str = '';
var strBuf = [];
if (pos + limit > end)
limit = end - pos;
for (var n = 0; n < limit; ++n)
str += String.fromCharCode(stream.getByte());
for (var n = 0; n < limit; ++n) {
strBuf.push(String.fromCharCode(stream.getByte()));
}
var str = strBuf.join('');
stream.pos = pos;
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
if (index == -1)

View file

@ -2382,11 +2382,11 @@ var Font = (function FontClosure() {
}
function arrayToString(arr) {
var str = '';
for (var i = 0, ii = arr.length; i < ii; ++i)
str += String.fromCharCode(arr[i]);
return str;
var strBuf = [];
for (var i = 0, ii = arr.length; i < ii; ++i) {
strBuf.push(String.fromCharCode(arr[i]));
}
return strBuf.join('');
}
function int16(bytes) {
@ -2801,10 +2801,11 @@ var Font = (function FontClosure() {
for (var i = 0, ii = strings.length; i < ii; i++) {
var str = proto[1][i] || strings[i];
var strUnicode = '';
for (var j = 0, jj = str.length; j < jj; j++)
strUnicode += string16(str.charCodeAt(j));
stringsUnicode.push(strUnicode);
var strBufUnicode = [];
for (var j = 0, jj = str.length; j < jj; j++) {
strBufUnicode.push(string16(str.charCodeAt(j)));
}
stringsUnicode.push(strBufUnicode.join(''));
}
var names = [strings, stringsUnicode];