pdf.js/src/core
Jonas Jenwald 8836593b9e Add a (global) cache to the getCharUnicodeCategory function
Given that the regular expression has already become more complex (after the initial patch adding it), it seems to me that it probably cannot hurt to add a global cache to reduce unnecessary re-parsing.
Obviously the `Glyph`-instances are being cached *per* font, however in most documents multiple fonts are being used and in practice there's very often a fair amount of overlap between the /ToUnicode-data in different fonts[1].

Consider for example loading and rendering the entire `tracemonkey.pdf` document (from the test-suite), which isn't a particularily large document. In that case the `getCharUnicodeCategory` function is being called a total of `601` times, however there's only `106` *unique* unicode-chars being checked.

*Please note:* In practice I suppose that this won't have a *huge* effect on overall performance, however given the relative simplicity of this patch I figured that it'd not hurt to submit it for review.

---
[1] Consider e.g. how there's usually different fonts used for regular, bold, respectively italic text.
2022-01-25 09:59:34 +01:00
..
xfa Merge pull request #14319 from calixteman/xfa_arc 2021-11-27 11:32:32 -08:00
.eslintrc Enable the ESLint no-var rule globally 2021-03-13 16:12:53 +01:00
annotation.js Handle non-integer Annotation border widths correctly (issue 14203) 2021-12-24 22:10:19 +09:00
arithmetic_decoder.js Re-factor how the ESLint no-var rule is enabled in the src/ folder 2020-10-03 20:15:29 +02:00
ascii_85_stream.js Fix the remaining ESLint operator-assignment errors 2021-07-04 15:23:56 +02:00
ascii_hex_stream.js Fix the remaining ESLint operator-assignment errors 2021-07-04 15:23:56 +02:00
base_stream.js Add a new BaseStream.getString(...) method to replace manual bytesToString(BaseStream.getBytes(...)) calls 2021-05-01 19:20:36 +02:00
bidi.js Tweak the Bidi-detection heuristics for very short RTL strings (issue 11656) 2021-11-03 20:31:57 +01:00
calibri_factors.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
catalog.js Add a (global) cache to the getCharUnicodeCategory function 2022-01-25 09:59:34 +01:00
ccitt_stream.js Move the DecodeStream and StreamsSequenceStream from src/core/stream.js and into its own file 2021-04-28 10:16:51 +02:00
ccitt.js Prevent an infinite loop when parsing corrupt /CCITTFaxDecode data (issue 14305) 2021-12-07 13:57:25 +01:00
cff_font.js Include and use the 14 standard fonts files. 2021-06-07 11:10:11 -07:00
cff_parser.js Enable the ESLint operator-assignment rule 2021-07-04 12:57:45 +02:00
charsets.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
chunked_stream.js Ensure that ChunkedStream won't attempt to request data *beyond* the document size (issue 14303) 2021-11-24 19:19:43 +01:00
cleanup_helper.js Add a (global) cache to the getCharUnicodeCategory function 2022-01-25 09:59:34 +01:00
cmap.js Handle ranges that "overflow" the last byte in CMap.mapBfRange (bug 1627427) 2021-10-24 13:48:38 +02:00
colorspace.js Enable the ESLint no-loss-of-precision rule 2021-11-14 10:48:50 +01:00
core_utils.js [Regression] Eagerly fetch/parse the entire /Pages-tree in corrupt documents (issue 14303, PR 14311 follow-up) 2021-12-02 14:31:04 +01:00
crypto.js [api-minor] Implement securityHandler in the scripting API (bug 1731578) 2021-10-26 23:42:04 +10:00
decode_stream.js Allow StreamsSequenceStream.readBlock to skip sub-streams with errors (issue 13794) 2021-07-26 16:42:50 +02:00
decrypt_stream.js Move the DecodeStream and StreamsSequenceStream from src/core/stream.js and into its own file 2021-04-28 10:16:51 +02:00
default_appearance.js [api-minor] Change the format of the fontName-property, in defaultAppearanceData, on Annotation-instances (PR 12831 follow-up) 2021-04-01 16:47:30 +02:00
document.js Add a (global) cache to the getCharUnicodeCategory function 2022-01-25 09:59:34 +01:00
encodings.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
evaluator.js Remove the invisible format marks from the text chunks 2022-01-24 13:47:24 +01:00
file_spec.js Remove the LGTM configuration and inline disable comments (issue 13829) 2021-08-03 11:14:49 +02:00
flate_stream.js Remove some, with Prettier 2.3.0, unnecessary // prettier-ignore comments 2021-05-19 11:36:03 +02:00
font_renderer.js Font renderer - get int8 instead of uint8 in composite glyphes (bug 1749563) 2022-01-18 22:06:23 +01:00
fonts_utils.js Include and use the 14 standard fonts files. 2021-06-07 11:10:11 -07:00
fonts.js Remove the invisible format marks from the text chunks 2022-01-24 13:47:24 +01:00
function.js Remove the closure used with the PostScriptStack class 2021-07-24 12:59:53 +02:00
glyf.js Font renderer - get int8 instead of uint8 in composite glyphes (bug 1749563) 2022-01-18 22:06:23 +01:00
glyphlist.js Enable the no-var linting rule in src/core/glyphlist.js 2021-02-27 12:46:57 +01:00
helvetica_factors.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
image_utils.js Re-factor the LocalTilingPatternCache to cache by Ref rather than Name (PR 12458 follow-up, issue 13780) 2021-08-18 12:49:01 +02:00
image.js Always prefer abbreviated keys, over full ones, when doing any dictionary lookups (issue 14256) 2021-11-10 11:56:18 +01:00
jbig2_stream.js Stop special-casing the dict parameter in the Jbig2Stream/JpegStream/JpxStream constructors 2021-04-28 13:44:47 +02:00
jbig2.js Re-factor the BaseException.name handling, and clean-up some code 2021-08-10 11:27:47 +02:00
jpeg_stream.js Always prefer abbreviated keys, over full ones, when doing any dictionary lookups (issue 14256) 2021-11-10 11:56:18 +01:00
jpg.js Enable the ESLint no-loss-of-precision rule 2021-11-14 10:48:50 +01:00
jpx_stream.js Stop special-casing the dict parameter in the Jbig2Stream/JpegStream/JpxStream constructors 2021-04-28 13:44:47 +02:00
jpx.js [FIX] fix jpx tag tree decode (issue 11957) 2021-08-31 11:44:26 +08:00
liberationsans_widths.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
lzw_stream.js Move the DecodeStream and StreamsSequenceStream from src/core/stream.js and into its own file 2021-04-28 10:16:51 +02:00
metadata_parser.js Move the XML-parser to the src/core/-folder 2021-02-17 13:12:01 +01:00
metrics.js Enable the no-var linting rule in src/core/metrics.js 2021-02-27 12:44:45 +01:00
murmurhash3.js Ensure that MurmurHash3_64.update handles ArrayBuffer input correctly, to avoid hash-collisions (issue 12533) 2020-10-26 16:27:33 +01:00
myriadpro_factors.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
name_number_tree.js Improve handling of named destinations in out-of-order NameTrees (PR 10274 follow-up) 2021-05-21 15:48:37 +02:00
object_loader.js Improve the handling getBaseStreams, on the various Stream implementations 2021-04-28 13:44:47 +02:00
opentype_file_builder.js Convert src/core/opentype_file_builder.js to use standard classes 2021-05-02 21:00:28 +02:00
operator_list.js [api-minor] Re-factor the *internal* renderingIntent, and change the default intent value in the PDFPageProxy.getAnnotations method 2021-08-06 00:39:42 +02:00
parser.js Prevent circular references in XRef tables from hanging the worker-thread (issue 14303) 2021-11-27 23:50:26 +01:00
pattern.js Always prefer abbreviated keys, over full ones, when doing any dictionary lookups (issue 14256) 2021-11-10 11:56:18 +01:00
pdf_manager.js [api-minor] Replace PDFDocumentProxy.getStats with a synchronous PDFDocumentProxy.stats getter 2021-11-20 12:20:55 +01:00
predictor_stream.js Always prefer abbreviated keys, over full ones, when doing any dictionary lookups (issue 14256) 2021-11-10 11:56:18 +01:00
primitives.js Prevent circular references in XRef tables from hanging the worker-thread (issue 14303) 2021-11-27 23:50:26 +01:00
ps_parser.js Remove the closure used with the PostScriptToken class 2021-07-24 13:05:46 +02:00
run_length_stream.js Move the DecodeStream and StreamsSequenceStream from src/core/stream.js and into its own file 2021-04-28 10:16:51 +02:00
segoeui_factors.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
standard_fonts.js Fallback to font name matching, when checking for serif fonts (issue 13845) 2021-09-23 01:11:57 +02:00
stream.js Add an abstract base-class, which all the various Stream implementations inherit from 2021-04-28 13:44:45 +02:00
struct_tree.js Include the /Lang-property, when it exists, in the StructTree-data (issue 14261) 2021-11-14 12:37:41 +01:00
to_unicode_map.js Convert src/core/to_unicode_map.js to use standard classes 2021-05-02 21:00:29 +02:00
type1_font.js Remove unnecessary MissingDataException check from getHeaderBlock 2021-05-03 13:57:30 +02:00
type1_parser.js Support Type1 font files with incomplete /CharStrings definitions (issue 14462) 2022-01-17 18:55:22 +01:00
unicode.js Add a (global) cache to the getCharUnicodeCategory function 2022-01-25 09:59:34 +01:00
worker_stream.js Replace a bunch of Array.prototype.forEach() cases with for...of loops instead 2021-04-24 13:00:19 +02:00
worker.js Add a (global) cache to the getCharUnicodeCategory function 2022-01-25 09:59:34 +01:00
writer.js Don't save anything in XFA entry if no XFA! (bug 1732344) 2021-09-23 19:51:23 +02:00
xfa_fonts.js XFA - Fix font scale factors (bug 1720888) 2021-07-28 19:10:42 +02:00
xml_parser.js Handle PI with no value in xml parser 2021-05-18 10:22:18 +02:00
xref.js [api-minor] Clear all caches in XRef.indexObjects, and improve /Root dictionary validation in XRef.parse (issue 14303) 2021-12-03 11:57:38 +01:00