Skip to content

possible performance reengineering #70

Description

@andrelsm

hi, WebCoder...

I spent some time tuning my highlighter (it's really fast now, a single regexp tokenizes the full text, generating the minimum number of nodes etc.) . Even so, handling typical files with around 600 lines (it's a good upper bound for me), CodeInput was not satisfactorily responsive. I've been wondering if I should implement highlighting only the visible scroll window at each input event, scheduling the full highlight with window.requestIdleCallback(). But I decided to try a hack first... and it seems to be giving satisfactory results by now...

The hack is to perform a kind of rendering throttling. This way:

// request redraw
el.must_redraw = true;
window.requestAnimationFrame(() => {
  if (el.must_redraw) {
    el.must_redraw = false;
    ulight_redraw(el, lang);
  } /*else {
    console.log('skipped');
  } */
});

When keystrokes are too fast, requests are queued; but instead of executing them FIFO, we jump to the current version of the text, ignoring the steps along the way.

This is a delicate change, so I didn't change your update() function, asking for a pull request.

When you have time, take a look, do some tests... Tell us what you think...

best regards
andrelsm

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions