Skip to content

Add helper methods for populating dateActionsCache/scandCache in the src/scripting_api/util.js file - #21681

Merged
timvandermeij merged 2 commits into
mozilla:masterfrom
Snuffleupagus:scripting-Util-getOrInsertComputed
Aug 6, 2026
Merged

Add helper methods for populating dateActionsCache/scandCache in the src/scripting_api/util.js file#21681
timvandermeij merged 2 commits into
mozilla:masterfrom
Snuffleupagus:scripting-Util-getOrInsertComputed

Conversation

@Snuffleupagus

@Snuffleupagus Snuffleupagus commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Rather than inlining all of that code, by moving it into separate helper methods we can utilize Map.prototype.getOrInsertComputed() instead.

Also, make a couple of the existing class fields actually private.


Much smaller diff with https://github.com/mozilla/pdf.js/pull/21681/changes?w=1

@codecov-commenter

codecov-commenter commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (5f181fd) to head (59cd456).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21681      +/-   ##
==========================================
+ Coverage   90.03%   90.05%   +0.01%     
==========================================
  Files         264      264              
  Lines       66939    66939              
==========================================
+ Hits        60267    60279      +12     
+ Misses       6672     6660      -12     
Flag Coverage Δ
browsertest 66.50% <ø> (+<0.01%) ⬆️
fonttest 9.03% <ø> (ø)
integrationtest 69.36% <ø> (+<0.01%) ⬆️
unittest 57.97% <ø> (+<0.01%) ⬆️
unittestcli 56.71% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Snuffleupagus
Snuffleupagus force-pushed the scripting-Util-getOrInsertComputed branch from 75c1c36 to e827000 Compare August 4, 2026 09:00
…the `src/scripting_api/util.js` file

Rather than inlining all of that code, by moving it into separate helper methods we can utilize `Map.prototype.getOrInsertComputed()` instead.

Also, make a couple of the existing class fields actually private.
….js`

Rather than only caching a string and then re-creating the regular expression on every `Util.prototype._scand` invocation, the entire regular expression can be cached directly instead.
@timvandermeij

Copy link
Copy Markdown
Collaborator

Nice refactoring; thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants