Skip to content

Speed up popup list rebuilds; fix ERB.new for Ruby 4 - #150

Open
dnwe wants to merge 3 commits into
ericpromislow:masterfrom
dnwe:popup-list-perf
Open

Speed up popup list rebuilds; fix ERB.new for Ruby 4#150
dnwe wants to merge 3 commits into
ericpromislow:masterfrom
dnwe:popup-list-perf

Conversation

@dnwe

@dnwe dnwe commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Two independent changes, one commit each:

  • perf: rebuilding the tab list no longer binds click/dblclick handlers per item (delegated to the list), appends items through a DocumentFragment, precomputes lowercase sort keys instead of lowercasing on every comparison, restores selection with a Set lookup, and assigns each item's textContent once
  • fix: the HTML templates now call ERB.new with keyword arguments; Ruby 4 removed the positional safe_level/trim_mode/eoutvar form, and the keyword form works on Ruby 2.6+ so existing 3.x builds are unaffected

Driving the generated popup script with 2000 synthetic tabs shows roughly 1.3x faster filtering per keystroke and a much cheaper select-all path; the win should be larger in a real browser since fewer reflows are triggered. Both the firefox and chrome zips build cleanly with make on Ruby 3.4 and 4.0.

@ericpromislow

Copy link
Copy Markdown
Owner

Looks good on reading through. The test is if the build works on my ancient laptop

@ericpromislow ericpromislow left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the version to VERSION=3.6.13 (master is currently at 3.6.12 so maybe you should pull master and rebase the fork)

@ericpromislow

Copy link
Copy Markdown
Owner

The build works with ruby 2.7.1p83 and erb 2.2.0, so that's a good thing

@dnwe

dnwe commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Please update the version to VERSION=3.6.13 (master is currently at 3.6.12 so maybe you should pull master and rebase the fork)

Sure, happy to bump the current one, but master is showing as 3.6.11 for me https://github.com/ericpromislow/tabhunter/blob/master/Makefile#L2 at the moment

@ericpromislow

Copy link
Copy Markdown
Owner

I forgot to push a change that just incremented the version field. It's fixed now. Pls rebase the branch and it should be fine

dnwe added 3 commits July 30, 2026 14:35
- Ruby 4 removed the positional safe_level/trim_mode/eoutvar form
- keyword form works on Ruby 2.6+ so 3.x builds are unaffected
- delegate li click/dblclick handlers to the list instead of rebinding per item
- append list items via a DocumentFragment rather than one at a time
- precompute lowercase sort keys instead of lowercasing on every comparison
- restore selection with a Set lookup rather than Array.indexOf
- build each item label in a string and assign textContent once
@dnwe
dnwe force-pushed the popup-list-perf branch from ac31cd0 to a76d57f Compare July 30, 2026 13:37
@dnwe

dnwe commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@ericpromislow sure, done!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants