Improve show-whitespace performance on large files#2737
Conversation
|
On my computer, the long https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts file performs terribly, with or without Refined GitHub. Now that I dropped the |
|
Will take a look at this once I'm back at a keyboard! |
This reverts commit 066402a. 5 times slower
So the loop won't hold the thread hostage for longer than 100ms at a time.
|
I tested This will make the whitespace appear a couple of frames later but I think it's worth it. I thought that |
|
@notlmn let me know today if you want to look at this because I’d like to merge it and publish a new version with this |
show-whitespaceshow-whitespace performance on large files
Closes #2732
I rewrote the feature to limit DOM manipulation. The previous one created a new DocumentFragment for each character, whether it was whitespace or not.
Even this version was slow until I cached
textNode.textContent; Firefox really doesn't like reading that many times in a loop. Now it's only read once per replacement, which makes the test URL instant. A related bug was opened here but closed asworksforme: https://bugzilla.mozilla.org/show_bug.cgi?id=1330475I wonder if manipulation could be further improved withEdit: tried, 5x slower: 066402aRange.surroundContentsbut the current solution seems fast enough.Current bugs:
=and{Test
Careful, this URL will freeze your Firefox window if you open it with the
masterversion of Refined GitHub: https://github.com/teropa/to-sting/blob/master/index.js