From 9b12c64be57e960be6ff1ccca026a58a25d32444 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 2 Oct 2015 12:46:58 +0200 Subject: [PATCH] Cache the regular expression used for finding `obj`s in `XRef_indexObjects`, to avoid unnecessary allocations --- src/core/obj.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/obj.js b/src/core/obj.js index 204fd3fb5..ca92b772a 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -1060,6 +1060,7 @@ var XRef = (function XRefClosure() { } return skipped; } + var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/; var trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]); var startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]); @@ -1097,7 +1098,7 @@ var XRef = (function XRefClosure() { position += skipUntil(buffer, position, trailerBytes); trailers.push(position); position += skipUntil(buffer, position, startxrefBytes); - } else if ((m = /^(\d+)\s+(\d+)\s+obj\b/.exec(token))) { + } else if ((m = objRegExp.exec(token))) { if (typeof this.entries[m[1]] === 'undefined') { this.entries[m[1]] = { offset: position - stream.start,